Comment #0 by jens.k.mueller — 2013-05-13T05:15:50Z
The following program causes dmd (dmd2.062) to segfault on Linux.
template foo(F)
{
enum foo = false;
}
bool foo(F)(F f)
if (foo!F)
{
return false;
}
void main()
{
foo(1);
}
$ dmd test.d
segmentation fault dmd test.d
I expect the program to compile or abort with an error but there should be no segfault.
Comment #1 by bugzilla — 2013-10-01T20:16:59Z
It's actually a stack overflow, endlessly repeating:
#61 0x080ba021 in ScopeExp::semantic (this=0x9fa2ee8, sc=0x9fa2f08) at expression.c:5018
#62 0x0817d987 in TemplateDeclaration::matchWithInstance (this=0x8294908, sc=0x9fa2978,
ti=0x9fa2858, dedtypes=0xff5ffa5c, fargs=0x0, flag=0) at template.c:928
#63 0x0818ad2e in TemplateInstance::ParamNeedsInf::fp (this=0xff5ffa50, s=0x8294908)
at template.c:6522
#64 0x0818a95d in TemplateInstance::ParamNeedsInf::fp (param=0xff5ffa50, s=0x8294908)
at template.c:6434
#65 0x080e6807 in overloadApply (fstart=0x8294428, param=0xff5ffa50,
fp=0x818a945 <TemplateInstance::ParamNeedsInf::fp(void*, Dsymbol*)>) at func.c:2446
#66 0x0818ae6b in TemplateInstance::needsTypeInference (this=0x9fa2858, sc=0x9fa2978, flag=0)
at template.c:6548
Comment #2 by bugzilla — 2013-10-01T20:50:09Z
It's looking at the constraint:
if (foo!F)
recursively in attempting to see if the template instantiation needs type inference.