Boost C++ Libraries: Ticket #7240: serialization backward compatibility issue with class_id_type attribute https://svn.boost.org/trac10/ticket/7240 <p> There is a backward compatibility issue in current boost::serialization around the class_id_type attribute. </p> <p> It is actually impossible to read binary archives written with boost 1.39 (format 5) with a boost release &gt; 1.43. </p> <p> For instance, with boost 1.47.0 : </p> <p> test_serialization: /home/ggagniard/dev/boost-1.47.0.bug/include/boost/archive/basic_archive.hpp:116: boost::archive::class_id_type::class_id_type(int): Assertion `t_ &lt;= boost::integer_traits&lt;base_type&gt;::const_max' failed. </p> <p> Please note that the same error still occurs with boost 1.50.0, the current stable release. </p> <p> After having a look at the class_id_type serialization in binary archives, I think I found the culprit : </p> <p> In boost/archive/basic_binary_iarchive.hpp : </p> <pre class="wiki"> void load_override(class_id_type &amp; t, int version){ library_version_type lvt = this-&gt;get_library_version(); if(boost::archive::library_version_type(7) &lt; lvt){ this-&gt;detail_common_iarchive::load_override(t, version); } else if(boost::archive::library_version_type(6) &lt; lvt){ int_least16_t x=0; * this-&gt;This() &gt;&gt; x; t = boost::archive::class_id_type(x); } else{ int x=0; * this-&gt;This() &gt;&gt; x; t = boost::archive::class_id_type(x); } } </pre><p> Here, archives whose version &lt;= 6 get their class_id_type read as an int ... </p> <p> However, in boost 1.43 (format 7) : </p> <pre class="wiki"> void load_override(class_id_type &amp; t, int){ // upto 32K classes int_least16_t x=0; * this-&gt;This() &gt;&gt; x; t = class_id_type(x); } </pre><p> It is clear than any library version &lt;= 7 have their class_id_type serialized as a int_least16_t, so the current load_override method is incorrect for versions &lt;= 6 ... </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7240 Trac 1.4.3 ggagniard@… Thu, 16 Aug 2012 10:43:13 GMT attachment set https://svn.boost.org/trac10/ticket/7240 https://svn.boost.org/trac10/ticket/7240 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_serialization_fix147.patch</span> </li> </ul> <p> Proposed patch on boost 1.47 (should apply on 1.50 too) </p> Ticket ggagniard@… Thu, 16 Aug 2012 10:46:03 GMT <link>https://svn.boost.org/trac10/ticket/7240#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7240#comment:1</guid> <description> <p> The proposed patch simply removes the special case for version 7 and reads class_id_type as an int_least16_t for any version &lt;= 7, which was the behaviour in previous boost releases. </p> </description> <category>Ticket</category> </item> <item> <author>ggagniard@…</author> <pubDate>Wed, 20 Nov 2013 16:50:17 GMT</pubDate> <title>type, severity changed https://svn.boost.org/trac10/ticket/7240#comment:2 https://svn.boost.org/trac10/ticket/7240#comment:2 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Regression</span> → <span class="trac-field-new">Showstopper</span> </li> </ul> <p> Any news ? I have used this patch for more than one year now and it hasn't caused any issue whatsover ... </p> <p> Do you know what could be done to integrate it in the trunk ? I don't like the idea of maintaining my own boost patches indefinitely ... </p> Ticket