4 ms·
> Properly executed RAII, at least in C++, should never break in the two cases you mention. So, std::shared_ptr (or anything else that does reference counting)
by rbehrends 11y ago
> Properly executed RAII, at least in C++, should never break in the two cases you mention.
So, std::shared_ptr (or anything else that does reference counting) is not properly executed RAII?
> Debuggers too are usually well aware of out-of-scope objects, so I don't see the point here.
I wasn't talking about debuggers, but code that is enabled for debugging purposes. E.g. globally remembering the last N objects passed to a function.
My larger point is that either lifetime or reachability is off. You either have a resource that can still be accessed through a stale handle even though it's been deallocated or one that remains allocated past its intended lifetime.