C#
Using fixed arrays in struct, without recursion.and loading (Compile x86 or AnyCPU)struct
into the stack for an operation.
public unsafe struct Godzilla
{
public const int Size = 40900;
fixed double data[Size];
public Godzilla(double init)
{
fixed(double* ptr=data)
{
for(int i=0; i<Size; i++)
{
ptr[i]= init;
}
}
}
public void Add(Godzilla other)
{
fixed(double* ptr=data)
{
for(int i=0; i<Size; i++)
{
ptr[i]+=other.data[i];
}
}
}
}
class Program
{
static void Main(string[] args)
{
Godzilla A=new Godzilla(1.0);
Godzilla B=new Godzilla(2.0);
A.Add(B);
}
}
It tries to load all the values on the stack and fails. Each struct is 8×40900 = 327,200 bytes long and when two of them get loaded into the stack it pukes.