RCArray is unsafe
Zach the Mystic via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 2 17:31:57 PST 2015
On Tuesday, 3 March 2015 at 01:23:24 UTC, Zach the Mystic wrote:
> Which makes me think about a bigger problem... when you
> opAssign, don't you redirect the variable to a different
> instance? Won't the destructor then destroy *that* instance (or
> not destroy it, since it just got a +1 count) instead of the
> one most recently decremented? How does it hold onto the
> instance to be destroyed?
auto y = new RcStruct;
y = null;
y's old RcStruct gets decremented to zero, but who owns it now?
Whose destructor ever gets run on it?
More information about the Digitalmars-d