Re: [Boost-bugs] [Boost C++ Libraries] #3604: Access violation on diamond inheritance

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3604: Access violation on diamond inheritance
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-29 17:52:30


#3604: Access violation on diamond inheritance
----------------------------------+-----------------------------------------
  Reporter: kondo@… | Owner: ramey
      Type: Bugs | Status: closed
 Milestone: Boost 1.41.0 | Component: serialization
   Version: Boost 1.40.0 | Severity: Problem
Resolution: invalid | Keywords:
----------------------------------+-----------------------------------------
Changes (by ramey):

  * status: reopened => closed
  * resolution: => invalid

Comment:

 The library does a downcast from VBase * to Target * which is illegal in
 C++ if VBase is a virtual base class. However msvc doesn't always detect
 this and will sometimes work anyway. The following code WILL do the
 serialization, but not through a virtual base class pointer.


 {{{
     // Serialize pTarget
     {
         std::ofstream ofs("outtarget.xml");
         boost::archive::xml_oarchive oa(ofs);
         assert(ofs);
         Target* pTarget = new Target;
         oa << boost::serialization::make_nvp("pTarget", pTarget);
     }
     {
         std::ifstream ifs("outtarget.xml");
         assert(ifs);
         boost::archive::xml_iarchive ia(ifs);
         Target* pTarget = new Target;
         ia >> boost::serialization::make_nvp("pTarget", pTarget);
         // if you want you could then use
         VBase *pVbase = pTarget.
     }
 }}}

 the way you want to do can't be done in legal/portable C++ even though it
 seems to work sometimes with MSVC.

 Robert Ramey

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3604#comment:4>
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:01 UTC