Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-06-23 16:47:16


Jason House wrote:
> I have the contents of a shared pointer getting corrupted by a default
> constructor of another object. My best guess as to how this could be
> happening is that I am using references to shared pointers for coding
> convenience.
>
> Is it possible for code like the following to cause a problem?
>
> {
> boost::shared_ptr<my_class> &x = a.b.c.d.e.f.g;
> if (x.get() == NULL)
> { pointer_empty(); }
> else
> { other_actions(x->get()); }
> }

I don't think so, unless other_actions( p ) does delete p.

When you #define BOOST_SP_ENABLE_DEBUG_HOOKS in your project and link with
libs/smart_ptr/src/sp_debug_hooks.cpp, do you get any assertions?


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