Boost logo

Boost Users :

Subject: Re: [Boost-users] Thread Safety of shared_ptr
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-05-02 08:16:13


Kevin Frey wrote:
> Hello,
>
> I wish to clarify a point on the thread-safety of shared_ptr. [...]

> //--- Example 4 ---
> // thread A
> p3 = p2; // reads p2, writes p3
>
> // thread B
> // p2 goes out of scope: undefined, the destructor is considered a
> "write access"

This example just says that you can't make a copy of a destroyed shared_ptr,
or one that is in the process of being destroyed. In principle, it has
nothing to do with reference counts. Doing something with a destroyed object
of any type is undefined behavior in C++.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net