Opened 6 years ago

#12641 new Bugs

binary_oarchive_impl constructor calls derived class before it is constructed.

Reported by: Jess Peterson <jess@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.62.0 Severity: Problem
Keywords: CRTP derived base constructor Cc:

Description

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.

Change History (0)

Note: See TracTickets for help on using tickets.