I checked, the base did not have a virtual destructor (I didn't write it!!), but even adding that, the code still bus errors. Is there anything specific I need to add for serialisation of shared_ptr and derived classes? Currently I just have the serialise functions in all the classes being serialised. I already call the base class serialisation using base_obect in the derived classes serialize functions, but I haven't added the BOOST_CLASS_EXPORT_GUID stuff referred to in certain parts of the docs as I thought that it should work without it - reason being it doesn't throw unregistered_class, it bus errors. Strangely, I have now tried to use the BOOST_CLASS_EXPORT_GUID macros in the derived class, and they cause a compile fault along the lines of... BOOST_CLASS_EXPORT_GUID(LCTextPanel, "TextPanel"); causes
whole load of template faults I don't understand then... ../boost_1_33_1/boost/archive/basic_xml_archive.hpp:66: error : incomplete type 'boost::STATIC_ASSERTION_FAILURE< false>' used in nested name specifier ../boost_1_33_1/boost/archive/basic_xml_archive.hpp:66: error : size of array has non-integral type '<type error>'
So if anyone knows what that means as it might be what's causing the other issue....?? James -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Richard Damon Sent: 02 May 2007 12:19 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialisation] Question on shared_ptr'sand base/derived classes One comment is that: Class A { }; // No virtual destructor Class B : public A { } shared_ptr<A>(new B) Should cause UB as the shared pointer will will eventually call delete on its parameter, and since A has no virtual destructor and is NOT the type the object was created with, you get UB. It basically boils down to the equivalent to this A* ptr = new B; delete ptr; which is a no-no. A NEEDS to have a virtual destructor to use it the way you are. Richard _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users This message (including any attachments) contains confidential and/or proprietary information intended only for the addressee. Any unauthorized disclosure, copying, distribution or reliance on the contents of this information is strictly prohibited and may constitute a violation of law. If you are not the intended recipient, please notify the sender immediately by responding to this e-mail, and delete the message from your system. If you have any questions about this e-mail please notify the sender immediately.