Bug 9111 – Parent object getting GCed before the elements of child dynamic array
Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-03T00:51:00Z
Last change time
2012-12-03T02:43:56Z
Assigned to
nobody
Creator
puneet
Comments
Comment #0 by puneet — 2012-12-03T00:51:58Z
The following code segfaults when compiled with current DMD github snapshot. It seems that array elements of "frop" are getting garbage collected after the parent class Foo's object is collected.
Works fine with dmd-2.059 and dmd-2.060.
class Frop {
bar _v;
}
struct bar {
static Foo _root;
~this() {
_root.del();
}
}
class Foo {
int _x;
Frop[] _frop;
this() {
bar._root = this;
_frop = [new Frop()];
}
void del() {}
}
void main() {
auto foo = new Foo ;
}