Thread overview
Silent crash when template recursion limit exceeded
Oct 27, 2005
Don Clugston
Oct 28, 2005
Thomas Kuehne
Nov 05, 2005
Walter Bright
Nov 05, 2005
Kramer
October 27, 2005
EXAMPLE 1.
Compiler just returns to command line, no message.
--------
template a(int n)
{
   const int b = a!(n-1).b;
}

int main()
{
 return a!(50).b;
}
---------
EXAMPLE 2 -- Borderline case, may help with debugging?

It happens at a precise point. On my system, this crashes, but it
compiles OK if the limit is changed to (n<3233).
---------
template a(int n)
{
  static if (n<3234)
   const int b = a!(n+1).b;
   else const int b=0;
}

int main()
{
 return a!(0).b;
}
October 28, 2005
Don Clugston schrieb am 2005-10-27:
> EXAMPLE 1.
> Compiler just returns to command line, no message.
> --------
> template a(int n)
> {
>     const int b = a!(n-1).b;
> }
>
> int main()
> {
>   return a!(50).b;
> }
> ---------
> EXAMPLE 2 -- Borderline case, may help with debugging?
>
> It happens at a precise point. On my system, this crashes, but it compiles OK if the limit is changed to (n<3233).
> ---------
> template a(int n)
> {
>    static if (n<3234)
>     const int b = a!(n+1).b;
>     else const int b=0;
> }
>
> int main()
> {
>   return a!(0).b;
> }

Added to DStress as http://dstress.kuehne.cn/nocompile/t/template_17_A.d

Thomas


November 05, 2005
"Don Clugston" <dac@nospam.com.au> wrote in message news:djq89r$1i6e$1@digitaldaemon.com...
> EXAMPLE 1.
> Compiler just returns to command line, no message.
> --------
> template a(int n)
> {
>     const int b = a!(n-1).b;
> }
>
> int main()
> {
>   return a!(50).b;
> }
> ---------
> EXAMPLE 2 -- Borderline case, may help with debugging?
>
> It happens at a precise point. On my system, this crashes, but it compiles OK if the limit is changed to (n<3233).

What's happening is it overflows up the stack. I suppose I could put a recursion limit in there, after all, what on earth would one be doing recursing over 1000 ? <g>


November 05, 2005
In article <dkhvdt$15fl$4@digitaldaemon.com>, Walter Bright says...
>
>
>"Don Clugston" <dac@nospam.com.au> wrote in message news:djq89r$1i6e$1@digitaldaemon.com...
>> EXAMPLE 1.
>> Compiler just returns to command line, no message.
>> --------
>> template a(int n)
>> {
>>     const int b = a!(n-1).b;
>> }
>>
>> int main()
>> {
>>   return a!(50).b;
>> }
>> ---------
>> EXAMPLE 2 -- Borderline case, may help with debugging?
>>
>> It happens at a precise point. On my system, this crashes, but it compiles OK if the limit is changed to (n<3233).
>
>What's happening is it overflows up the stack. I suppose I could put a recursion limit in there, after all, what on earth would one be doing recursing over 1000 ? <g>
>
>

Would that recursion limit be part of the language spec. or the compiler implementation?  I would favor it as part of the compiler implementation.  The great thing about computers and programming is that as much as one tries, you can never really predict how they'll be used.  I tend to favor creating things that are not limited to "moment in time" restrictions (i.e. storing the year in two position fields instead of 4).  My $.02 though. :)

Cheers,
-Kramer

P.S. I feel the same way about the static array size limit of 16Mb in the language spec.  And no, I couldn't give an example of needing something larger, but, that's not really the point. <g>