www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Minor bug in dmd

It hangs on infinite template recursion recursion. For example:

template factorial(int n)
{
  enum { factorial = n* .factorial!(n-1) }
}

template factorial(int n : 1)
{
  enum { factorial = 1 }
}

void test()
{
  printf("%d\n", factorial!(-4));      // hangs
}

In gnu g++ it is solved by limiting recursion level.

-- 
          Vladimir
Mar 31 2005