Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5340: Patch to support concrete base classes becomming abstract classes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-05-11 07:08:19
#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.47.0 | Severity: Showstopper
Resolution: | Keywords: serialization abstract concrete
----------------------------------------------+-----------------------------
Comment (by Aaron Barany <akb825@â¦>):
This isn't when a serialize function is calling serialize on its base
class, this is when serializing into a pointer of a polymorphic type. For
example:
{{{
#!c++
MyClass* c;
a >> c;
}}}
The problem isn't that it's trying to call serialize, the problem is
templates are being instantiated that reference the serialize function.
Before, it was never instantiating pointer_iserializer<MyClass> if Myclass
was abstract, but that would cause mismatches if MyClass started as
concrete, then later became abstract. Now I am always instantiating
pointer_iserializer<MyClass>, and when the type registration mismatch
occurs on load it is registered as if it were concrete.
The exact template instantiation chain is: pointer_iserializer<MyClass>
instantiates iserializer<MyClass>, which uses access to call serialize on
MyClass. Even if it's never actually executing the code that calls
serialize on MyClass, the compiler still expects it to be there.
After thinking about it a little more and looking at where it registers
the serializer, it's actually not as easy to cut off the reference to
serialize as I thought. I thought I could use stub out the
iserializer<MyClass> instantiation in pointer_iserializer<MyClass> if
MyClass is abstract, but that won't work if MyClass is serialized anywhere
else. (such as from a subclass' serialize function) What I will need to do
is stub out the iserializer<MyClass> instantiation if MyClass doesn't have
a serialize function. Fortunately, such a check is possible.
(http://groups.google.com/group/comp.lang.c++/msg/1a3b6e58852ef3af)
This also brings up another interesting case: if MyClass in my example
above is actually a concrete base class without a serialize function, it
will also fail to compile even without my patches applied. With a
mechanism in place to detect if a serialize function exists, I can have it
so serializing MyClass will compile if MyClass doesn't have a serialize
function, regardless of whether MyClass is abstract or not, as long as it
is polymorphic.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5340#comment:4> 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