Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-01-18 00:25:44


One can't invoke any function of the derived class through a base class
pointer unless the base class is polymorphic - that is has at least one
virtual function.

Serialization is no different in this regard.

I would not expect the behavior of the program below to
change between version.

The error message is the same as those failures in test_export
but the cause isn't necessarily the same.

I would be curious of the version 1.36 serialization library
at rrsd.com would pass tests with gcc 4.1 and higher.

Robert Ramey

Boris Gubenko wrote:
> x.cpp below reproduces failures of test_exported* tests on
> several platforms using gcc 4.1 and higher. The tests fail with:
>
> terminate called after throwing an instance of
> 'boost::archive::archive_exception'
> what(): unregistered void cast
>
> When compiled with macro WORKS defined, i.e. when destructor of
> the base class is removed, reproducer succeeds. Does it give any
> clue?
>
> Thanks,
> Boris
>
> x.cpp
> -----
> #include <fstream>
> #include <boost/archive/binary_oarchive.hpp>
>
> struct polymorphic_base
> {
> template<class Archive>
> void serialize(Archive&, const unsigned int) {}
> #ifndef WORKS
> virtual ~polymorphic_base(){}
> #endif
> };
>
> struct polymorphic_derived : polymorphic_base
> {
> template<class Archive>
> void serialize(Archive&, const unsigned int) {}
> };
>
> int main()
> {
> std::ofstream os("x.x");
> boost::archive::binary_oarchive oa(os);
> polymorphic_base *rb = new polymorphic_derived;
> oa << BOOST_SERIALIZATION_NVP(rb);
> }
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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