Bug 858 – Forward reference to struct inside class crashes the compiler

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-01-19T14:35:00Z
Last change time
2014-02-15T13:12:38Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
georg.ramme
Blocks
340

Comments

Comment #0 by georg.ramme — 2007-01-19T14:35:59Z
E:\prog\>dmd dontwork.d --- The instruction as "0x004565b9" referenced memory at "0x00000038". The memory could not be "read". --- E:\prog\>dmd work.d E:\apps\dm\bin\link.exe work,,,user32+kernel32/noi; /** dontwork.d **/ class Outer { public: this() { B sc = new B(); } class B { Strct str; } } struct Strct { int i; } int main(char[][] args) { return 0; } /** work.d **/ struct Strct { int i; } class Outer { public: this() { B sc = new B(); } class B { Strct str; } } int main(char[][] args) { return 0; } ***
Comment #1 by thomas-dloop — 2007-02-23T16:43:12Z
Comment #2 by kamm-removethis — 2008-11-04T05:04:10Z
The code generation seems to crash because the vthis member of Inner's ClassDeclaration is NULL. This happens when semantic is called again from runDeferredSemantic: first vthis is set to baseClass->vthis (baseClass is Object and vthis there is NULL) and then the interface and nested code isn't run again to correct it because sizeok != 0.
Comment #3 by kamm-removethis — 2008-11-04T05:10:49Z
I looked at the code in dstress, not the one posted here. The Inner in my description is georg's inner B class.
Comment #4 by clugdbug — 2009-05-14T05:04:02Z
No longer segfaults in DMD2.040 and 1.030. Still doesn't compile (generates a forward reference error). However, the original bug is fixed. TEST CASE: --- class A{ class B { S s; } void foo() { B b = new B(); } } struct S {} --- ice.d(6): Error: forward reference to B