Bug 2215 – Forward reference enum with base type within a struct causes Segmentation Fault in the compiler

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-07-10T13:32:00Z
Last change time
2015-06-09T01:19:51Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
schveiguy
Blocks
340

Comments

Comment #0 by schveiguy — 2008-07-10T13:32:22Z
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.
Comment #3 by clugdbug — 2009-05-14T07:27:38Z
Fixed DMD2.030.