Bug 8664 – Compiler causes stack overflow with recursive typedef and option -g
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-15T05:19:00Z
Last change time
2013-11-16T02:42:24Z
Keywords
ice, pull
Assigned to
nobody
Creator
r.sagitario
Comments
Comment #0 by r.sagitario — 2012-09-15T05:19:38Z
The file fail4.d from the dmd test suite causes a stack overflow when generating debug information at the same time. The code is
typedef foo bar;
typedef bar foo;
Without "-g" on the command line, dmd reports:
test.d(3): Error: typedef test.foo circular definition
If dmd is compiled with the Microsoft compiler instead of dmc, this function
type *TypeTypedef::toCtype()
{
return sym->basetype->toCtype();
}
in toctype.c is tail recursion optimized, which results in a freeze.
The problem does not happen with "alias", because the recursion is dealt with in the front end:
test.d(2): Error: alias test.bar recursive alias declaration