씨#
정말 크고 struct
재귀가 없으며 순수한 C #이며 안전하지 않은 코드는 아닙니다.
public struct Wyern
{
double a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
}
public struct Godzilla
{
Wyern a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
}
public struct Cyclops
{
Godzilla a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
}
public struct Titan
{
Cyclops a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
}
class Program
{
static void Main(string[] args)
{
// An unhandled exception of type 'System.StackOverflowException' occurred in ConsoleApplication1.exe
var A=new Titan();
// 26×26×26×26×8 = 3655808 bytes
Console.WriteLine("Size={0}", Marshal.SizeOf(A));
}
}
키커로서 디버그 창에 충돌을 일으켜 {Cannot evaluate expression because the current thread is in a stack overflow state.}
그리고 일반 버전 (NPSF3000 제안에 감사드립니다)
public struct Wyern<T>
where T: struct
{
T a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
}
class Program
{
static void Main(string[] args)
{
// An unhandled exception of type 'System.StackOverflowException' occurred in ConsoleApplication1.exe
var A=new Wyern<Wyern<Wyern<Wyern<int>>>>();
}
}