Subject: [Boost-bugs] [Boost C++ Libraries] #5340: Patch to support concrete base classes becomming abstract classes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-19 00:26:28
#5340: Patch to support concrete base classes becomming abstract classes
---------------------------------------------+------------------------------
Reporter: Aaron Barany <akb825@â¦> | Owner: ramey
Type: Patches | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.46.0 | Severity: Problem
Keywords: serialization abstract concrete |
---------------------------------------------+------------------------------
If you are serializing a pointer to a polymorphic object as a pointer to
its base class, and that base class is concrete, it will fail to load if
that base class later becomes abstract. That is because the serializer for
the base class is automatically registered if it is concrete, but not if
it is abstract, making a mismatch in the class id for the object. I have
attached a patch that detects this case and registers the serializer for
the abstract class if it occurs.
This patch contains multiple pieces. Fist, basic_iarchive.cpp is patched
in load_pointer() to detect that mismatch in class ids and register the
serializer. Second, iserializer.hpp is patched so that register_type() for
abstract classes returns the proper pointer serializer. (though it isn't
directly registered) Third, pointer_iserializer::load_object_pointer() now
uses templates to split into two implementations: one for abstract and one
for non-abstract classes. The abstract implementation throws an
archive_exception, to which an abstract_class_error field has been added.
This patch does not handle going from an abstract base class to a concrete
base class, as that would break backwards compatibility. However, it
should be more common to go from concrete to abstract than the other way
around, and having this support can solve a lot of debugging headaches
when it comes up. (headaches that prompted me adding this support)
I have tried to keep consistent with your coding style and techniques to
make it as seamless to patch as possible.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5340> 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:06 UTC