RCArray is unsafe

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 3 07:01:02 PST 2015


On 3/3/15 5:05 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" wrote:
> The object is still accessible after its refcount went to zero, and can
> therefore potentially be resurrected. Probably not a problem, but needs
> to be taken into account, in particular in with respect to the freelist.
> That's tricky, because an object can be released and resurrected several
> times, and care must be taken that it will not end up in the freelist
> and get destroyed multiple times. And that hasn't even touched on
> thread-safety yet.

Could you please give an example?

> The bigger problem is that it's relying on a convention. The RC wrapper
> needs to be constructed in a particular way that's easy to get wrong and
> that the compiler has no way to check for us.

Agreed.


Andrei



More information about the Digitalmars-d mailing list