[shared_ptr] Ticket 2126 status?

Hi, Is the ticket 2126: http://svn.boost.org/trac/boost/ticket/2126 actually fixed in trunk? The ticket is still open, but my code that uses enable_shared_from_this and make_shared runs fine on trunk. However, the issue is still present in the release branch. If the problem is actually fixed, and the fixture doesn't break anything else I'd like to ask to merge the change to the release branch. Thanks.

Andrey Semashev:
Is the ticket 2126:
http://svn.boost.org/trac/boost/ticket/2126
actually fixed in trunk? The ticket is still open, but my code that uses enable_shared_from_this and make_shared runs fine on trunk.
Interesting. No, I don't believe that trunk is OK. The constructor support just masks the problem. Try for example the following test: #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/make_shared.hpp> #include <boost/detail/lightweight_test.hpp> struct X: boost::enable_shared_from_this<X> { bool destroyed_; X(): destroyed_( false ) {} ~X() { destroyed_ = true; } }; int main() { boost::shared_ptr<X> px = boost::make_shared<X>(); boost::shared_ptr<X> px2 = px->shared_from_this(); BOOST_TEST( px == px2 ); BOOST_TEST( !( px < px2 ) && !( px2 < px ) ); px.reset(); BOOST_TEST( !px2->destroyed_ ); return boost::report_errors(); }

Peter Dimov wrote:
Andrey Semashev:
Is the ticket 2126:
http://svn.boost.org/trac/boost/ticket/2126
actually fixed in trunk? The ticket is still open, but my code that uses enable_shared_from_this and make_shared runs fine on trunk.
Interesting. No, I don't believe that trunk is OK. The constructor support just masks the problem. Try for example the following test:
Right, this one fails, indeed. I guess, I've been lucky so far since I didn't encounter any problems. Thanks for pointing this out.

Peter Dimov wrote:
Andrey Semashev:
Is the ticket 2126:
http://svn.boost.org/trac/boost/ticket/2126
actually fixed in trunk? The ticket is still open, but my code that uses enable_shared_from_this and make_shared runs fine on trunk.
Interesting. No, I don't believe that trunk is OK. The constructor support just masks the problem. Try for example the following test:
I tried to dig the code here and there. It seems like calling sp_accept_owner for the constructed object would settle the problem. I modified make_shared.hpp accordingly and tried your test on Linux (GCC 4.3), and it passed without errors. I also tried the make_shared_test.cpp test and it also passed. Please, find the patch attached. Is it valid?
participants (2)
-
Andrey Semashev
-
Peter Dimov