Subject: [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-16 18:50:13
#9255: Serialization of negative long value to stringstream throws exception.
------------------------------+---------------------------
Reporter: iatkinson@⦠| Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------
I am using the boost 1.54 serialization with the binary archive to
serialize some basic data. This works great across several platforms in
all cases except one. When I try to serialize a negative long value an
exception is raised on OS X 10.7.5 building with clang 425.0.28.
For example, the following example works fine on Windows 8 (visual studio
2012) and Ubuntu (gcc) but fails on OS X (clang).
{{{
#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;
// 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;
}
}}}
I can get the above to work by doing any of the following:
- Changing to from binary archives to text archives
- Using a type other than long (e.g, signed int is fine)
- Assigning a positive value to original (but keeping type a long)
- Using file streams instead of string streams
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9255> 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