[Boost-bugs] [Boost C++ Libraries] #9567: De-serialization of enable_shared_from_this through base class pointer fails

Subject: [Boost-bugs] [Boost C++ Libraries] #9567: De-serialization of enable_shared_from_this through base class pointer fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-13 10:53:22


#9567: De-serialization of enable_shared_from_this through base class pointer
fails
-------------------------------------------------+-------------------------
 Reporter: Tim Regan | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component:
  Version: Boost 1.53.0 | serialization
 Keywords: serialization | Severity: Problem
  enable_shared_from_this shared_ptr weak_ptr |
-------------------------------------------------+-------------------------
 Given the following class structure:
    Base is a simple class.
    Derived inherits from Base.
    Derived also inherits from boost::enable_shared_from_this<Derived>.
    Base and Derived implement boost::serialization.

 When deserializing an instance of Derived into a vector of
 boost::shared_ptr<Derived>:
    Base and Derived members are reconstructed correctly.
    Derived::shared_from_this() works as expected.

 But when deserializing an instance of Derived into a vector of
 boost::shared_ptr<Base>:
    Base and Derived members are still reconstructed correctly.
    Derived::shared_from_this() throws a bad_weak_ptr exception.
    This is because enable_shared_from_this::weak_ptr is NOT reconstructed
 - It is zero.

 See test code in attached file that demonstrates both of the above cases.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9567>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC