id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 2180,Errors on binary serialization of vector,k_karanikolas@…,Matthias Troyer,"I am encountering compiler errors when trying to serialize objects stored in a vector, using boost 1.35, as well as boost svn. Here's a simplified test case {{{ #include #include #include #include #include void test() { std::vector vec; std::ofstream ofs(""file""); // boost::archive::text_oarchive oarc(ofs); // Compiles fine under both GCC 4.0.1 and GCC 4.1 boost::archive::binary_oarchive oarc(ofs); // Compiles under GCC 4.0.1 but not GCC 4.1. Also compiles fine with boost 1.34/GCC 4.1 oarc & vec; } }}} Whereas serializing to a text archive works fine under both compilers, binary serialization triggers compiler errors under GCC 4.1 ------------------ {{{ /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp: In instantiation of ‘const int boost::mpl::aux::template_arity_impl >::use_array_optimization, 3>::value’: /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:93: instantiated from ‘const int boost::mpl::aux::template_arity >::use_array_optimization>::value’ /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:98: instantiated from ‘boost::mpl::aux::template_arity >::use_array_optimization>’ /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/apply.hpp:48: instantiated from ‘boost::mpl::apply1 >::use_array_optimization, int>’ /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp:53: instantiated from ‘boost::serialization::use_array_optimization::apply’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: instantiated from ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:85: error: call of overloaded ‘arity_helper(boost::mpl::aux::type_wrapper >::use_array_optimization>, boost::mpl::aux::arity_tag<3>)’ is ambiguous /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:30: note: candidates are: char (& boost::mpl::aux::arity_helper(...))[1] /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:51: note: char (& boost::mpl::aux::arity_helper(boost::mpl::aux::type_wrapper >, boost::mpl::aux::arity_tag<3>))[4] [with F = boost::archive::basic_binary_oprimitive::use_array_optimization, T1 = boost::archive::binary_oarchive, T2 = char, T3 = std::char_traits] /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:51: note: char (& boost::mpl::aux::arity_helper(boost::mpl::aux::type_wrapper >, boost::mpl::aux::arity_tag<3>))[4] [with F = boost::archive::basic_binary_oprimitive::use_array_optimization, T1 = boost::archive::binary_oarchive, T2 = char, T3 = std::char_traits] /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp: In instantiation of ‘const int boost::mpl::aux::template_arity >::use_array_optimization>::value’: /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:98: instantiated from ‘boost::mpl::aux::template_arity >::use_array_optimization>’ /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/apply.hpp:48: instantiated from ‘boost::mpl::apply1 >::use_array_optimization, int>’ /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp:53: instantiated from ‘boost::serialization::use_array_optimization::apply’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: instantiated from ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:93: error: ‘’ is not a valid template argument for type ‘int’ because it is a non-constant expression /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp: In instantiation of ‘boost::mpl::aux::template_arity >::use_array_optimization>’: /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/apply.hpp:48: instantiated from ‘boost::mpl::apply1 >::use_array_optimization, int>’ /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp:53: instantiated from ‘boost::serialization::use_array_optimization::apply’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: instantiated from ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp:98: error: ‘’ is not a valid template argument for type ‘int’ because it is a non-constant expression /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/apply.hpp: In instantiation of ‘boost::mpl::apply1 >::use_array_optimization, int>’: /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp:53: instantiated from ‘boost::serialization::use_array_optimization::apply’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: instantiated from ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/mpl/aux_/preprocessed/gcc/apply.hpp:48: error: ‘’ is not a valid template argument for type ‘int’ because it is a non-constant expression /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp: In instantiation of ‘boost::serialization::use_array_optimization::apply’: /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: instantiated from ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/archive/binary_oarchive.hpp:53: error: no type named ‘type’ in ‘struct boost::mpl::apply1 >::use_array_optimization, int>’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp: In function ‘void boost::serialization::save(Archive&, const std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’: /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:45: instantiated from ‘static void boost::serialization::free_saver::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/split_free.hpp:74: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:139: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector&, unsigned int) [with Archive = boost::archive::binary_oarchive, U = int, Allocator = std::allocator]’ /Users/kostas/develop/ext/boost/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ /Users/kostas/develop/ext/boost/boost/archive/detail/oserializer.hpp:144: instantiated from ‘void boost::archive::detail::oserializer::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive, T = std::vector >]’ test3.cpp:15: instantiated from here /Users/kostas/develop/ext/boost/boost/serialization/vector.hpp:119: error: no type named ‘type’ in ‘struct boost::serialization::use_array_optimization::apply’ }}} ---------------------- My compiler versions are {{{ Using built-in specs. Target: powerpc-apple-darwin9 Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --program-prefix= --host=powerpc-apple-darwin9 --target=powerpc-apple-darwin9 Thread model: posix gcc version 4.0.1 (Apple Inc. build 5465) }}} {{{ Using built-in specs. Target: psp Configured with: ../configure --prefix=/Users/kostas/develop/psp/pspdev --target=psp --enable-languages=c,c++ --with-newlib --enable-cxx-flags=-G0 Thread model: single gcc version 4.1.0 (PSPDEV 20060507) }}} Thanks in advance ",Bugs,closed,To Be Determined,serialization,Boost 1.35.0,Problem,fixed,,