Problem with boost serialization with an existing 'struct load'

Please send me a copy of any replies to this message. The following code compiles with boost_1_31_0 but fails with 1_32_0 and 1_33_1 (tested with gcc 3.2.2 and gcc 4.0.3 on Linux systems): // ------------------------------------------------------------------- #include <boost/archive/xml_iarchive.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/split_member.hpp> #include <iostream> struct K { friend class boost::serialization::access; template<class Archive> void save(Archive &ar, const unsigned int version) const {} template<class Archive> void load(Archive &ar, const unsigned int version) {} BOOST_SERIALIZATION_SPLIT_MEMBER() }; struct load { int x; }; int main(void) { std::vector<K> v; boost::archive::xml_iarchive ia( std::cin ); ia & boost::serialization::make_nvp("v", v); return 0; } // ------------------------------------------------------------------- We would like to move our application from boost 1_31 but this problem with 'struct load' has stopped us so far. Is this a bug in BOOST serialization in 1_32 and 1_33 that will be corrected in the future, or do we have no choice but to rename our 'struct load'? If this is the correct behavior of the serialization library, is it noted anywhere in the documentation? I was unable to find such a note. Jeff

It compiled fine on my current setup - VC 7.1 with boost 1.35 (Boost Head) so I'm not sure what to tell you. You might want to wait for 1.34 (real soon now) and try it there. Robert Rmaey

Please send me a copy of any replies to this message. On Tue, Oct 03, 2006 at 10:50:00AM -0500, Jeff Epler wrote:
The following code compiles with boost_1_31_0 but fails with 1_32_0 and 1_33_1 (tested with gcc 3.2.2 and gcc 4.0.3 on Linux systems): [snipped]
At the suggestion of Robert Ramey, I also tried rc_1_34_0 from CVS. It has the same problem: $ g++ -I. -c serialization-struct-load-test.cc -O3 -fmessage-length=0 ./boost/serialization/split_free.hpp: In static member function ‘static void boost::serialization::free_loader<Archive, T>::invoke(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]’: ./boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]’ ./boost/serialization/vector.hpp:68: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector<U, Allocator>&, unsigned int) [with Archive = boost::archive::xml_iarchive, U = K, Allocator = std::allocator<K>]’ ./boost/serialization/serialization.hpp:140: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]’ ./boost/archive/detail/iserializer.hpp:158: instantiated from ‘void boost::archive::detail::iserializer<Archive, T>::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]’ serialization-struct-load-test.cc:23: instantiated from here serialization-struct-load-test.cc:17: error: ‘struct load’ is not a function, ./boost/archive/detail/iserializer.hpp:550: error: conflict with ‘template<class Archive, class T> void boost::archive::load(Archive&, T&)’ ./boost/serialization/split_free.hpp:58: error: in call to ‘load’ I did not re-test any other versions of gcc, but I do not expect the outcome to differ. Jeff Epler jepler@dsndata.com

I was able to reproduce the problem using your example on my my gcc 3.3 compiler. I can't explain it though- and for what its worth no other compiler has a complaint with this. Sorry I can't give a better answer. Robert Ramey Jeff Epler wrote:
Please send me a copy of any replies to this message.
On Tue, Oct 03, 2006 at 10:50:00AM -0500, Jeff Epler wrote:
The following code compiles with boost_1_31_0 but fails with 1_32_0 and 1_33_1 (tested with gcc 3.2.2 and gcc 4.0.3 on Linux systems): [snipped]
At the suggestion of Robert Ramey, I also tried rc_1_34_0 from CVS. It has the same problem:
$ g++ -I. -c serialization-struct-load-test.cc -O3 -fmessage-length=0 ./boost/serialization/split_free.hpp: In static member function 'static void boost::serialization::free_loader<Archive, T>::invoke(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K>
]': ./boost/serialization/split_free.hpp:74: instantiated from 'void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]' ./boost/serialization/vector.hpp:68: instantiated from 'void boost::serialization::serialize(Archive&, std::vector<U, Allocator>&, unsigned int) [with Archive = boost::archive::xml_iarchive, U = K, Allocator = std::allocator<K>]' ./boost/serialization/serialization.hpp:140: instantiated from 'void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]' ./boost/archive/detail/iserializer.hpp:158: instantiated from 'void boost::archive::detail::iserializer<Archive, T>::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::archive::xml_iarchive, T = std::vector<K, std::allocator<K> >]' serialization-struct-load-test.cc:23: instantiated from here serialization-struct-load-test.cc:17: error: 'struct load' is not a function, ./boost/archive/detail/iserializer.hpp:550: error: conflict with 'template<class Archive, class T> void boost::archive::load(Archive&, T&)' ./boost/serialization/split_free.hpp:58: error: in call to 'load'
I did not re-test any other versions of gcc, but I do not expect the outcome to differ.
Jeff Epler jepler@dsndata.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Please send me a copy of any replies to this message. The patch below (against the RC_1_34_0 version from CVS) adds the test program for the "struct load" bug to the serialization library's test suite. This program fails with post-1_31 versions of boost on all the gcc systems I have access to, including gcc 3.2.2, gcc 4.0.2, and gcc 4.0.3. However, the program did work with boost 1_31 on gcc 3.2.2, so from my viewpoint it's a regression in boost. Index: libs/serialization/test/Jamfile =================================================================== RCS file: /cvsroot/boost/boost/libs/serialization/test/Jamfile,v retrieving revision 1.34.2.1 diff -u -p -u -r1.34.2.1 Jamfile --- libs/serialization/test/Jamfile 5 Apr 2006 04:56:10 -0000 1.34.2.1 +++ libs/serialization/test/Jamfile 4 Oct 2006 21:32:00 -0000 @@ -246,6 +246,7 @@ test-suite "serialization" : [ test-bsl-run_files test_shared_ptr ] [ test-bsl-run_files test_shared_ptr_132 ] [ test-bsl-run_polymorphic_archive test_polymorphic : test_polymorphic_A ] + [ compile test_struct_load.cpp ] ; if $(BOOST_SERIALIZATION_TEST) { Index: libs/serialization/test/Jamfile.v2 =================================================================== RCS file: /cvsroot/boost/boost/libs/serialization/test/Jamfile.v2,v retrieving revision 1.3 diff -u -p -u -r1.3 Jamfile.v2 --- libs/serialization/test/Jamfile.v2 17 Mar 2006 07:36:47 -0000 1.3 +++ libs/serialization/test/Jamfile.v2 4 Oct 2006 21:32:00 -0000 @@ -263,6 +263,7 @@ test-suite "serialization" : [ test-bsl-run_files test_shared_ptr ] [ test-bsl-run_files test_shared_ptr_132 ] [ test-bsl-run_polymorphic_archive test_polymorphic : test_polymorphic_A ] + [ compile test_struct_load.cpp ] ; if $(BOOST_SERIALIZATION_TEST) { --- /dev/null 2006-09-22 07:23:40.969060500 -0500 +++ libs/serialization/test/test_struct_load.cpp 2006-10-04 09:17:21.000000000 -0500 @@ -0,0 +1,25 @@ +#include <boost/archive/xml_iarchive.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/split_member.hpp> +#include <iostream> + +struct K { + friend class boost::serialization::access; + template<class Archive> + void save(Archive &ar, const unsigned int version) const + {} + template<class Archive> + void load(Archive &ar, const unsigned int version) + {} + BOOST_SERIALIZATION_SPLIT_MEMBER() +}; + +struct load { int x; }; + +int main(void) { + std::vector<K> v; + boost::archive::xml_iarchive ia( std::cin ); + ia & boost::serialization::make_nvp("v", v); + return EXIT_SUCCESS; +} +
participants (2)
-
Jeff Epler
-
Robert Ramey