Boost logo

Boost :

From: Paul Roberts (usenet_at_[hidden])
Date: 2008-03-23 11:17:55


Hi,

I just upgraded from trunk for the first time in a few weeks, and now
I'm unable to compile classes that use serialization and have private
destructors. It seems boost::serialization::extended_type_info_typeid is
now trying to access those destructors, and failing.

Do I need to friend extended_type_info_typeid now, as well as
boost::serialization::access, or is this a genuine bug? I've provided a
minimal repro case below, followed by the compiler output from MSVC 9.

Regards,

-- 
Paul Roberts
paul at pwroberts dot com
http://www.m3fe.com/

#include <boost/serialization/access.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <fstream>

class A
{
        friend class boost::serialization::access;
private:
        ~A() {}

        template<typename Archive> void serialize(Archive& ar,
                const unsigned int version)
        {
        }

public:
        static A a;
};

A A::a;

int main()
{
        std::ofstream ofs("hi");
        {
                boost::archive::binary_oarchive oa(ofs);
                oa << A::a;
        }
}

/*

1>------ Build started: Project: 2k8test, Configuration: Release Win32 ------
1>Compiling...
1>serialization_fun.cpp
1>C:\dev\boost-trunk\boost/serialization/extended_type_info_typeid.hpp(118) : error C2248: 'A::~A' : cannot access private member declared in class 'A'
1> .\serialization_fun.cpp(18) : compiler has generated 'A::~A' here
1> .\serialization_fun.cpp(7) : see declaration of 'A'
1> C:\dev\boost-trunk\boost/serialization/extended_type_info_typeid.hpp(117) : while compiling class template member function 'void boost::serialization::extended_type_info_typeid<T>::destroy(const void *const ) const'
1> with
1> [
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(110) : see reference to class template instantiation 'boost::serialization::extended_type_info_typeid<T>' being compiled
1> with
1> [
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(107) : while compiling class template member function 'boost::archive::detail::oserializer<Archive,T>::oserializer(void)'
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(234) : see reference to class template instantiation 'boost::archive::detail::oserializer<Archive,T>' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(228) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive &,const T &)'
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(292) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(280) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive &,const T &)'
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(498) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save<Archive,const T>(Archive &,const T &)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/array/oarchive.hpp(118) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<const T>(T &,int)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/basic_binary_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::array::oarchive<Archive>::save_override<T>(const T &,unsigned int)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/binary_oarchive_impl.hpp(45) : see reference to function template instantiation 'void boost::archive::basic_binary_oarchive<Archive>::save_override<T>(const T &,int)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1> C:\dev\boost-trunk\boost/archive/detail/interface_oarchive.hpp(63) : see reference to function template instantiation 'void boost::archive::binary_oarchive_impl<Archive,Elem,Tr>::save_override<T>(T &,int)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> Elem=char,
1> Tr=std::char_traits<char>,
1> T=A
1> ]
1> .\serialization_fun.cpp(27) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<A>(T &)' being compiled
1> with
1> [
1> Archive=boost::archive::binary_oarchive,
1> T=A
1> ]
1>Build log was saved at "file://c:\dev\work\2k8test\Release\BuildLog.htm"
1>2k8test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

*/


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