Bug 3684 – Stack overflow on wrong template instantiation syntax with typeof
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-01-07T03:17:00Z
Last change time
2015-06-09T01:27:14Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
bugzilla
Comments
Comment #0 by bugzilla — 2010-01-07T03:17:05Z
The following (incorrect) code causes DMD to segfault on compilation:
template Foo(T) if (is(T == int))
{
enum bool Foo = true;
}
template Foo(T) if (!is(T == int))
{
enum bool Foo = Foo(typeof(int.min));
}
static assert (Foo!double);
In the second template, note the following two things which are BOTH required to reproduce the bug:
1) The ! is missing from the template instantiation.
2) The template parameter is typeof(int.min) instead of just int.