Boost C++ Libraries: Ticket #11423: Serialization with versioning not working with (pure virtual) base classes https://svn.boost.org/trac10/ticket/11423 <p> The versioning feature of the serialization component works fine when using with non-polymorphic classes or derived classes. However, for (pure virtual) base classes the version number set with BOOST_CLASS_VERSION(<a class="missing wiki">MyBaseClass</a>, 1) seems to be ignored and during serialization the default version (=0) is always used. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11423 Trac 1.4.3 Robert Ramey Fri, 26 Jun 2015 15:04:49 GMT <link>https://svn.boost.org/trac10/ticket/11423#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11423#comment:1</guid> <description> <p> I can't imagine why this would be a problem. </p> <p> In order to help with this, I'd really have to see a small example demonstrating the problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 30 Jun 2015 10:37:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11423#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11423#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11423#comment:1" title="Comment 1">ramey</a>: </p> <blockquote class="citation"> <p> I can't imagine why this would be a problem. </p> <p> In order to help with this, I'd really have to see a small example demonstrating the problem. </p> </blockquote> <p> I stepped through the code and found that what I'm observing (version number ignored) is due to a different reason, though serializing an inheritance hierarchy may be heavily affected by this issue. </p> <p> Here is what I found: Consider the following class structure that are contained in two different modules (compilation units). </p> <p> =========== ModuleA.dll =========== </p> <p> class ClassA { </p> <blockquote> <p> template&lt;class Archive&gt; void serialize(Archive &amp;ar, const unsigned int uiVersion); </p> </blockquote> <p> }; </p> <p> BOOST_CLASS_VERSION(ClassA, 1) </p> <p> =========== ModuleA.dll =========== <br /> <br /> =========== ModuleB.dll =========== </p> <p> class ClassB : public ClassA { </p> <blockquote> <p> template&lt;class Archive&gt; void serialize(Archive &amp;ar, const unsigned int uiVersion) { </p> <blockquote> <p> ar &amp; BOOST_SERIALIZATION_BASE_OBJECT_NVP(ClassA); </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> BOOST_CLASS_VERSION(ClassB, 1) </p> <p> =========== ModuleB.dll =========== </p> <p> Now consider the following call stack: </p> <p> [...]<br /> ModuleB.dll!ClassB::serialize(...) &lt;- this triggers BOOST_SERIALIZATION_BASE_OBJECT_NVP(ClassA); <br /> [...]<br /> ModuleB.dll!oserializer&lt;Archive, ClassA&gt;::save_object_data(...) &lt;- this call uses ::boost::serialization::version&lt;ClassA&gt;::value <br /> </p> <p> The problem now is that ::boost::serialization::version&lt;ClassA&gt;::value evaluates to 0 as the specialization (version <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a>) is only known inside ModuleA. </p> <p> I think this should be a new ticket if this is indeed the issue... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 29 Sep 2015 22:09:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11423#comment:3 https://svn.boost.org/trac10/ticket/11423#comment:3 <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> is the resolved? As I haven't heard anything lately, I'm going to close this ticket </p> Ticket