Bug 1669 – this.outer in nested classes gives a bogus pointer
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-11-14T15:03:00Z
Last change time
2015-06-09T05:14:48Z
Keywords
wrong-code
Assigned to
ibuclaw
Creator
jarrett.billingsley
Comments
Comment #0 by jarrett.billingsley — 2007-11-14T15:03:51Z
Have some code:
module foo;
import tango.io.Stdout;
abstract class Base
{
void foo();
}
class A
{
void print()
{
Stdout.formatln("I'm A!");
}
Base getBase()
{
return new class Base
{
override void foo()
{
this.outer.print();
}
};
}
}
void main()
{
auto a = new A();
auto b = a.getBase();
b.foo();
}
This causes a segmentation fault. If you inspect this.outer, it's completely bogus -- this.outer.classinfo is filled with garbage, etc. This same code works fine when compiled with DMD on Linux.