Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3365: Serialization of multi_index_container is non portable.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-23 09:32:19
#3365: Serialization of multi_index_container is non portable.
------------------------------------------------------+---------------------
Reporter: Ilia V. Sochenkov <ivsochenkov@â¦> | Owner: joaquin
Type: Bugs | Status: reopened
Milestone: Boost 1.40.0 | Component: multi_index
Version: Boost 1.38.0 | Severity: Problem
Resolution: | Keywords: multi_index_container serialization, multi_index
------------------------------------------------------+---------------------
Changes (by Hajo Kirchhoff <mailinglists@â¦>):
* cc: mailinglists@⦠(added)
* status: closed => reopened
* resolution: fixed =>
* severity: Cosmetic => Problem
Comment:
The changeset may fix this problem (haven't checked), but line 667 (of
this changeset) might cause data truncation under x64 bit and a compiler
warning.
{{{
serialization::collection_size_type s;
detail::serialization_version<value_type> value_version;
if(version<1){
std::size_t sz;
ar>>serialization::make_nvp("count",sz);
s=sz; /***** Error here *****/
}
}}}
With x64 bit compilation (Visual Studio 2008, boost 1.44)
collection_size_type is unsigned int (32 Bit), whereas size_t is an
unsigned long (64 Bit). The assignment s=sz gets truncated and issues a
warning
boost\boost/multi_index_container.hpp(673) : error C4267: 'argument' :
conversion from 'size_t' to 'const unsigned int', possible loss of data
Since our project treats this warning as an error, the code does not
compile.
The patch here is straightforward: simply cast the result. There is
nothing we can do in this case anyway and also it is pretty unlikely that
any user in the world will serialise more than 2^32 items.
{{{
@@ -670,7 +670,7 @@
if(version<1){
std::size_t sz;
ar>>serialization::make_nvp("count",sz);
- s=sz;
+ s=(serialization::collection_size_type)sz;
}
else{
ar>>serialization::make_nvp("count",s);
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3365#comment:3> 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:07 UTC