Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9255: Serialization of negative long value to stringstream throws exception.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-10-28 17:43:42
#9255: Serialization of negative long value to stringstream throws exception.
-------------------------------+---------------------------
Reporter: iatkinson@⦠| Owner: ramey
Type: Bugs | Status: reopened
Milestone: To Be Determined | Component: serialization
Version: Boost 1.54.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------------
Comment (by ramey):
I'm concerned about the fact that the output stream isn't closed before
reading the file back. Try the following changes in your example and see
if it makes a difference
{{{
#include <sstream>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
int main(int argc, char * argv[])
{
long original = -1; // A non-negative value works fine
long value = 0;
{
// Serialize
std::ostringstream oss;
boost::archive::binary_oarchive out(oss);
out << original;
} // leaving scope closes both the archive and the stream thus making
sure no data is left in buffers
{
// Deserialize
std::istringstream iss(oss.str());
boost::archive::binary_iarchive in(iss);
in >> value; // exception raised here on OS X if original is a
long < 0
}
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9255#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:14 UTC