Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-09-28 08:02:59


Ben Hutchings wrote:
> John Torjo <john.lists_at_[hidden]> wrote:
>> Ben Hutchings wrote:
> <snip>
>>> expired() may read the count as still being 1 and so return false,
>>> but I believe the wnd_shared_ptr constructor will catch the fact
>>> that the pointer really has expired. Unfortunately I can't yet
>>> see the code to confirm this!
>>
>> By looking at the code, I would think not. But I may be wrong.
>> Anyway, I've posted the code in my other post.
>
> Thanks for that. Supposing that expired() wrongly returns false
> because use_count is really 0 but it gets an old non-zero value.
> Then lock() attempts to construct a shared_ptr: [...]

It is also worth noting that no matter how you fiddle with the
implementation of atomic_read() that is indirectly invoked by expired(), it
would still be possible for the use_count to drop to zero _after_ expired()
has returned.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk