Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2002: bugs in load_binary and save_binary on 64 bit machines
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-14 20:49:42
#2002: bugs in load_binary and save_binary on 64 bit machines
----------------------------------------------------------+-----------------
Reporter: MIchele De Stefano <micdestefano_at_[hidden]> | Owner: troyer
Type: Bugs | Status: closed
Milestone: Boost 1.35.1 | Component: serialization
Version: Boost 1.35.0 | Severity: Regression
Resolution: invalid | Keywords: load_binary save_binary 64 bit
----------------------------------------------------------+-----------------
Changes (by troyer):
* status: new => closed
* resolution: => invalid
Comment:
The bug is in your code. You write:
ar.save_binary(data,Nel*sizeof(size_t));
while data is an array of type T, which in your example is float. On 32
bit machines this works by chance since there
sizeof(float)==sizeof(size_t), but on 64-bit machines a size_t is bigger
than a float. This is the reason for the bug. It is much safer to just
serialize using array wrappers:
ar << serialization::make_array(data,Nel)
which gets the correct size automatically
Matthias
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2002#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:49:58 UTC