|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-09-01 03:44:44
David Abrahams wrote:
> Second Issue:
>
> I found the following code in shared_array (and I assume the analogous code
> is in shared_ptr):
>
> void reset(T* p=0)
> {
> if ( px == p ) return; // fix: self-assignment safe
>
> What this does is to make a silent success of resetting a shared_ptr with
> the pointer it owns.
[...]
> I'd rather see an assert() here.
A similar issue has come up with Boost.Thread, where some simple
case of deadlock can be easily detected, but more complicated ones
cannot. I think the resolution was not to detect the simple case
and specify a reaction to it, but instead treat all cases as a
precondition violation (with undefined behaviour).
David's case is similar.
I second David's suggestion above: It's a precondition violation
which should be handled by an assert(), if easy to detect.
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk