Is this a bug?
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 4 08:59:52 PDT 2014
On 5/4/2014 7:39 PM, monarch_dodra wrote:
>
> Really??? I knew there was no guarantee in which order the destructor
> were run, but at the very least, I thought you had a guarantee of
> dependency ordering?
"Furthermore, the order in which the garbage collector calls destructors
for unreference objects is not specified. This means that when the
garbage collector calls a destructor for an object of a class that has
members that are references to garbage collected objects, those
references may no longer be valid."
http://dlang.org/class.html#destructors
In this case, CHello does not maintain a reference to the object. But
even if it did, the destruction is happening at app termination and all
bets are off. My understanding is that gc.term just blows through all
the objects still on the heap without any regard to who still references
what.
> ...
>
> Then again, the GC can collect cycles, so...
>
> Well dang. That's a bummer.
More information about the Digitalmars-d-learn
mailing list