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);
}