Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-09 12:37:54


From: "Thomas Witt" <witt_at_[hidden]>
> What actually happens at end of main is
>
> 1) b goes out of scope
> 2) the shared_count of the B object goes to zero
> 3) B::dispose gets called
> 4) scoped_ptr<A>::reset deletes the A object the first time.
> 5) The destructor for A::b_ gets called
> 6) the weak_count for the B object goes to zero
> 7) The destructor for the B object is called.
> 8) the destructor for B::a_ is called
> Note that we are still in scoped_ptr<A>::reset
> scoped_ptr<A>::ptr still points to the A object
> that is currently destructed.
> 10) scoped_ptr<A>::~scoped_ptr<A> calls the destructor
> for ptr the second time.
> 11) We have managed to wreck the heap.

Another indication that you can't beat copy+swap correctness-wise. OK, I've
fixed scoped_ptr::reset (although I've some trouble communicating with the
CVS server so the changes aren't committed yet.) The self-reset "feature" is
still there; should we remove it as well for 1.29 or can this wait?


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