Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2001-10-18 02:22:14


on 10/18/01 12:19 AM, AlisdairM at AlisdairM_at_[hidden] wrote:

> Is the following also a bug?
>
> [...]
>
> int main()
> {
> foo x = 5;
> boost::shared_ptr<fo> px( &x );
> }
>
> This strikes me as an error in user code, as something other than the
> scoped_ptr is responsible for the lifetime of the passed pointer.

It's definitely an error.

> The original example is the same problem, although better disguised.

I don't agree. I don't think they are related.

The issue in the original example is the lifetime of the shared_ptr itself,
not the lifetime of the pointed-to object.

    -- Darin


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