Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-09-30 19:05:31


Kim Barrett wrote:
>> Brian Schrom wrote:
>> > There are a few other warning messages if you care to know about
>> them:
>>>
>>> ./boost/archive/polymorphic_iarchive.hpp:60: warning: 'class
>>> boost::archive::polymorphic_iarchive' has virtual functions but
>> > non-virtual destructor
>
> At 9:04 PM -0700 9/29/06, Robert Ramey wrote:
>> This is explained in the code in the cited place. it turns out
>> that for particular reasons, polymophic archives can't be
>> destroyed through the base class pointer. For this
>> reason, the destructor is marked "protected"
>
> The explanation in that comment is:
>
> ... there is no way to forward to the "true" destructor.
>
> I would have thought that simply making the polymorphic_[i,o]archive
> destructors virtual (as was discussed a few weeks ago when I brought
> up the problem of destructor slicing for these classes) would solve
> this problem. What am I overlooking?

Well, that's what I thought. Then I looked into it. When I tried it
I got problems due the the fact that the most derived class is
derived from multiple bases. see
http://www.boost.org/libs/serialization/doc/class_diagram.html
It's easy to see by making the change to "virtual" with your original
example.

I didn't see an easy way to fix it and I didn't see it as a big
problem so I just punted.

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk