DMD-0.164 regressions
Walter Bright
newshound at digitalmars.com
Thu Aug 17 13:37:11 PDT 2006
class_26_A and class_26_B are invalid code. Both return a delegate that
relies on the stack frame of foo() existing, but the delegate is called
after foo() has exited.
More technically,
1. dg contains the 'this' pointer for the instance of class C
2. the instance of class C contains a member that is the frame
pointer for the stack instance of foo()
3. the stack instance of foo() contains a frame pointer for the
stack instance of main()
dg(), to get at main.status, has to walk back through 1, 2 and 3. After
foo() has exited, (2) points to garbage, and so cannot get a correct
value for (3), and failure ensues.
This will be an excellent test case when D implements the ability for
delegates to 'escape', but that won't be for 1.0.
More information about the Digitalmars-d-bugs
mailing list