Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-11-19 02:56:50

Robert, I think I've finally figured out why test_void_cast was failing with
gcc. Consider the following code:

 BOOST_CHECK(vpa == boost::serialization::void_upcast(

    BOOST_CHECK(vpb == boost::serialization::void_upcast(

The first call fails to find direct cast from MostDerived to Base1. So it
finds a chain of casts and registers the final found cast: i.e. it creates a
new instance of void_caster. That instances stores both from_type and

But... it stores them by reference. In this case, the reference points to
temporary objects you've created in function call. So, after the first call
is done, you have void_caster from MostDerived to Base1, but the references
in that void_caster are invalid -- they refer to temporary objects that were
destroyed after the call.

The second call creates a fresh pair of temporary objects, *at the same memory
address*. So, the void_caster instance suddenly becomes caster from
MostDerived to Base2. Of course, it does not work quite nice. If I use the
'get_instance' method of extended_type_info_typeid, the simplified version of
test_void_cast.cpp I was using starts to work.

Is there any chance you'll make the fix for all the calls to void_cast in
test_void_cast.cpp and send me the updated version so that I could test

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at