Subject: [Boost-bugs] [Boost C++ Libraries] #5106: std::bad_cast thrown in the boost::archive::basic_binary_(o|i)primitive constructor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-01-22 02:00:12
#5106: std::bad_cast thrown in the boost::archive::basic_binary_(o|i)primitive
constructor
--------------------------------------------------------+-------------------
Reporter: gleize.pierre@⦠| Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.45.0 | Severity: Problem
Keywords: bad_cast serialization archive constructor |
--------------------------------------------------------+-------------------
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!cpp
std::ofstream ofs( "./test.dat" );
::boost::archive::binary_oarchive oa( ofs );
}}}
}}}
Tested with gcc 4.6 on MacOSX, this simple piece of code throws a
std::bad_cast exception with Boost 1.45.0
I found a quick fix.
Replace this :
{{{
#!div style="font-size: 80%"
include/boost/archive/basic_binary_oprimitive.hpp
{{{#!cpp
108 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
109 basic_binary_oprimitive(
110 std::basic_streambuf<Elem, Tr> & sb,
111 bool no_codecvt
112 );
}}}
}}}
By this :
{{{
#!div style="font-size: 80%"
include/boost/archive/basic_binary_oprimitive.hpp
{{{#!cpp
108 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
109 basic_binary_oprimitive(
110 std::basic_streambuf<Elem, Tr> & sb,
111 bool no_codecvt
112 ) : m_sb( sb )
113 #ifndef BOOST_NO_STD_LOCALE
114 , locale_saver( sb )
115 #endif
116 {};
}}}
}}}
Same modifications for the file basic_binary_'''i'''primitive.hpp.
I'm not sure this is the right thing to do, and I don't understand why the
constructor didn't have any body.
Is there a default behavior for that kind of constructor ?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5106> 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:05 UTC