Bug 928 – nested struct definition in unittest section of a templated class, hangs DMD

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-02-03T14:01:00Z
Last change time
2014-02-16T15:22:44Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
dkm4i1

Comments

Comment #0 by dkm4i1 — 2007-02-03T14:01:20Z
The following code seems to make the compiler do some endless loop, because of the TestType definition. ______________________________________________________ void main() { MinHeap!(int) foo = new MinHeap!(int)(); } class MinHeap(NodeType) { unittest { struct TestType {} MinHeap!(TestType) foo = new MinHeap!(TestType)(); } }
Comment #1 by thomas-dloop — 2007-04-05T11:33:39Z
Comment #2 by clugdbug — 2009-08-12T11:29:31Z
Straightforward patch. This is just a copy-and-paste of the code for the other recursive template expansion checks. Patch against DMD 2.031. Index: template.c =================================================================== --- template.c (revision 194) +++ template.c (working copy) @@ -3592,7 +3592,27 @@ if (sc->func || dosemantic3) { +#if WINDOWS_SEH + __try + { +#endif + if (++nest > 500) + { + global.gag = 0; // ensure error message gets printed + error("recursive expansion"); + fatal(); + } semantic3(sc2); + --nest; +#if WINDOWS_SEH + } + __except (__ehfilter(GetExceptionInformation())) + { + global.gag = 0; // ensure error message gets printed + error("recursive expansion"); + fatal(); + } +#endif } Laftersemantic:
Comment #3 by bugzilla — 2009-10-13T13:49:58Z
Fixed dmd 1.049