Re: Why do I get stack overflow?

2009-05-25 Thread bearophile
Ary Borenszweig: Thanks. Later in my head I instantiated the template and noticed the problem. In time I have created similar problems in my code 2-3 times, missing a static before some if. Can't the compiler help spot such bugs? If the variables a dynamic if works on are constants

Why do I get stack overflow?

2009-05-24 Thread Ary Borenszweig
When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)(); return X * temp; } } const someVar = fact!(0)(); ---

Re: Why do I get stack overflow?

2009-05-24 Thread Christopher Wright
Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)(); return X * temp; } } const someVar = fact!(0)(); --- Like

Re: Why do I get stack overflow?

2009-05-24 Thread Moritz Warning
On Sun, 24 May 2009 20:49:53 -0300, Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X - 1)();

Re: Why do I get stack overflow?

2009-05-24 Thread Ary Borenszweig
Moritz Warning escribió: On Sun, 24 May 2009 20:49:53 -0300, Ary Borenszweig wrote: When I compile this code I get stack overflow printed in the console. Anyone know why? --- int fact(int X)() { if(X == 0) { return 1; } else { int temp = fact!(X