[Boost-bugs] [Boost C++ Libraries] #12641: binary_oarchive_impl constructor calls derived class before it is constructed.

Subject: [Boost-bugs] [Boost C++ Libraries] #12641: binary_oarchive_impl constructor calls derived class before it is constructed.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-12-01 23:46:57


#12641: binary_oarchive_impl constructor calls derived class before it is
constructed.
-------------------------------------------+---------------------------
 Reporter: Jess Peterson <jess@…> | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.62.0 | Severity: Problem
 Keywords: CRTP derived base constructor |
-------------------------------------------+---------------------------
 If I inherit from binary_oarchive_impl and hide the save_override method
 with one of my own,
 it gets called before my archive class is constructed.

 I call base class binary_orachive_impl constructor from my constructor.
 It calls its init() method
 which calls basic_binary_oarchive init() from
 detail/basic_binary_oarchive.ipp
 which calls this->This()::operator<< to output the file signature and
 version

 This() refers to my derived class which has not been constructed. Local
 variables required
 for the archive are not yet initialized. It is possible to avoid this by
 inheriting directly from oprimitive and oarchive and calling their init
 from the derived class but
 calling on a derived class from a base class constructor seems like a
 problem and the manual
 does say to inherit from the impl classes.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12641>
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:20 UTC