Bug 4768 – Regression(1.056): wrong code with forward declaration of enum

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2010-08-29T23:57:00Z
Last change time
2010-09-21T19:21:45Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
clugdbug
Blocks
340

Comments

Comment #0 by clugdbug — 2010-08-29T23:57:56Z
This is the D1 version of bug 4516. Rejected as 'forward reference error' up to D1.053. Worked correctly in 1.054 and 1.055. Wrong code in 1.056 and later. Works if the definition of B is moved above A. struct A { B b; } enum B { Z = 2 } void main() { A x; assert(x.b == 2); }
Comment #1 by clugdbug — 2010-09-13T16:39:04Z
mtype.c, line 4110. Basically the same patch as bug 4516. int TypeEnum::isZeroInit(Loc loc) { + if (!sym->isdone && sym->scope) + { // Enum is forward referenced. We need to resolve the whole thing. + sym->semantic(NULL); + } + if (!sym->isdone) + { + error(loc, "enum %s is forward referenced", sym->toChars()); + return 0; + } return (sym->defaultval == 0); }
Comment #2 by bugzilla — 2010-09-21T19:21:45Z