Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11423: Serialization with versioning not working with (pure virtual) base classes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-06-30 10:37:55
#11423: Serialization with versioning not working with (pure virtual) base classes
-------------------------------+---------------------------
Reporter: anonymous | Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.58.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------------
Comment (by anonymous):
Replying to [comment:1 ramey]:
> I can't imagine why this would be a problem.
>
> In order to help with this, I'd really have to see a small example
demonstrating the problem.
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.
Here is what I found:
Consider the following class structure that are contained in two different
modules (compilation units).
===========
ModuleA.dll
===========
class ClassA
{
template<class Archive>
void serialize(Archive &ar, const unsigned int uiVersion);
};
BOOST_CLASS_VERSION(ClassA, 1)
===========
ModuleA.dll
===========
[[BR]]
[[BR]]
===========
ModuleB.dll
===========
class ClassB : public ClassA
{
template<class Archive>
void serialize(Archive &ar, const unsigned int uiVersion)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(ClassA);
}
}
BOOST_CLASS_VERSION(ClassB, 1)
===========
ModuleB.dll
===========
Now consider the following call stack:
[...][[BR]]
ModuleB.dll!ClassB::serialize(...) <- this triggers
BOOST_SERIALIZATION_BASE_OBJECT_NVP(ClassA); [[BR]]
[...][[BR]]
ModuleB.dll!oserializer<Archive, ClassA>::save_object_data(...) <- this
call uses ::boost::serialization::version<ClassA>::value [[BR]]
The problem now is that ::boost::serialization::version<ClassA>::value
evaluates to 0 as the specialization (version #1) is only known inside
ModuleA.
I think this should be a new ticket if this is indeed the issue...
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11423#comment:2> 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:18 UTC