Boost C++ Libraries: Ticket #3365: Serialization of multi_index_container is non portable. https://svn.boost.org/trac10/ticket/3365 <p> multi_index_container save and load member-functions use type "std::size_t" to serialize a container's size instead of boost::serialization::collection_size_type. It may cause some problems when portable binary archives are used, because std::size_t has different size in different platforms. boost::serialization::collection_size_type can be treated specially by portable archive implementations: collection_size_type used in the serialization implementation for the standart containers. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3365 Trac 1.4.3 Joaquín M López Muñoz Thu, 03 Sep 2009 12:12:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3365#comment:1 https://svn.boost.org/trac10/ticket/3365#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/55994" title="fixed #3365">[55994]</a>) fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3365" title="#3365: Bugs: Serialization of multi_index_container is non portable. (closed: fixed)">#3365</a> </p> Ticket Joaquín M López Muñoz Thu, 03 Sep 2009 12:14:00 GMT <link>https://svn.boost.org/trac10/ticket/3365#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3365#comment:2</guid> <description> <p> Ilia, just fixed the problem in changeset </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/55994"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/55994</a> </p> <p> I'd appreciate if you could check everything's OK on your side. </p> </description> <category>Ticket</category> </item> <item> <author>Hajo Kirchhoff <mailinglists@…></author> <pubDate>Wed, 23 Nov 2011 09:32:18 GMT</pubDate> <title>status, severity changed; cc set; resolution deleted https://svn.boost.org/trac10/ticket/3365#comment:3 https://svn.boost.org/trac10/ticket/3365#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">mailinglists@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Cosmetic</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> 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. </p> <pre class="wiki"> serialization::collection_size_type s; detail::serialization_version&lt;value_type&gt; value_version; if(version&lt;1){ std::size_t sz; ar&gt;&gt;serialization::make_nvp("count",sz); s=sz; /***** Error here *****/ } </pre><p> 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 </p> <blockquote> <p> boost\boost/multi_index_container.hpp(673) : error C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data </p> </blockquote> <p> Since our project treats this warning as an error, the code does not compile. </p> <p> 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<sup>32 items. </sup></p> <pre class="wiki">@@ -670,7 +670,7 @@ if(version&lt;1){ std::size_t sz; ar&gt;&gt;serialization::make_nvp("count",sz); - s=sz; + s=(serialization::collection_size_type)sz; } else{ ar&gt;&gt;serialization::make_nvp("count",s); </pre> Ticket Joaquín M López Muñoz Thu, 24 Nov 2011 08:09:35 GMT <link>https://svn.boost.org/trac10/ticket/3365#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3365#comment:4</guid> <description> <p> Hi Hajo, </p> <p> Please check whether </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/75643"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/75643</a> </p> <p> solves the issue. Thank you! </p> </description> <category>Ticket</category> </item> <item> <author>Hajo Kirchhoff <mailinglists@…></author> <pubDate>Thu, 24 Nov 2011 09:22:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3365#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3365#comment:5</guid> <description> <p> Hi Joaquin, yes, that should solve the issue. Thanks. And thanks for your work :-) (fixed in 1.49) You can close this ticket again... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Thu, 24 Nov 2011 09:24:41 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3365#comment:6 https://svn.boost.org/trac10/ticket/3365#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket