This code causes a dmd segmentation fault:
struct S
{
E e;
}
enum E : int
{
E1
}
replace int with ubyte, also fails. I think this should be valid code because moving e outside the struct or putting it in a class works (no errors, no segfault).
The workaround is to declare the enum first.
Comment #1 by schveiguy — 2008-08-19T09:04:43Z
*** Bug 2290 has been marked as a duplicate of this bug. ***
Comment #2 by clugdbug — 2009-04-02T14:52:56Z
This is segfaulting in mtype.c, line 5156. If the enum is forward referenced, it doesn't know if it's default-initialised, so defaultval is null -> segfault.
int TypeEnum::isZeroInit()
{
return sym->defaultval->isBool(FALSE);
}
Unfortunately, 'loc' is not a parameter to isZeroInit, so I don't know how to give an error msg with missing line number.
There are actually two other places in TypeEnum where this problems happens:
isunsigned() uses memtype without checking.
hasPointers() uses toBaseType() without checking.
alignsize() probably gives error message without line number.