id summary reporter owner description type status milestone component version severity resolution keywords cc 1086 Serialization of weak_ptr produces invalid XML anonymous Robert Ramey "Hello, there seems to be a problem with serialization of weak_ptr. The second example below produces invalid XML where the same attributes appears two times with different values. It appears that both save and load using boost::serialization works, but other tools complains about the XML being invalid. We don't know if this is a problem in Boost.Serialization or in Boost.Archive The example has been tested using Boost 1.33.1 in Visual Studio 2005. We have not tested using Boost 1.34.0 yet. Anders Edin, Sidec Technologies AB ------------------------------------------------------------------------- {{{ #include #include #include #include #include #include #include #include #include class A { public: A() {} virtual ~A() {} virtual void set_self(boost::shared_ptr s) { self_ = s; } virtual boost::shared_ptr get_self() const { return self_.lock(); } private: friend boost::serialization::access; template void serialize(Archive& archive, const unsigned int file_version) { archive & boost::serialization::make_nvp(""self_"", self_); } boost::weak_ptr self_; }; BOOST_CLASS_VERSION(A, 1); class B: public A { public: B(): value_(3) {} virtual ~B() {} private: friend boost::serialization::access; template void serialize(Archive& archive, const unsigned int file_version) { archive & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); archive & boost::serialization::make_nvp(""value_"", value_); } int value_; }; BOOST_CLASS_VERSION(B, 1); int main(int argc, char* argv[]) { // This test object points to itself boost::shared_ptr a(new A()); a->set_self(a); // This test object also points to itself, but by pointing to its base class boost::shared_ptr b(new B()); b->set_self(b); // First example { boost::archive::xml_oarchive archive(std::cout); archive << boost::serialization::make_nvp(""A"", a); } std::cout< -- The second example produces invalid XML with attributes having two values in self_ 3 */ }}} " Bugs closed To Be Determined serialization Problem fixed