Boost logo

Boost Users :

Subject: [Boost-users] boost::serialization warnings for template class
From: Michele Vallisneri (m.vallis_at_[hidden])
Date: 2013-11-14 20:27:44


Dear Boost experts,

I'm serializing (intrusively) a template class Matrix<T> that includes a
double-pointer buffer of data of type T. So my save/load pair looks like

         template<class Archive> void save(Archive & ar, const unsigned int
version) const {
            ar & row_dim;
            ar & col_dim;

            for ( size_t i = 0; i < row_dim; i++ )
               for ( size_t j = 0; j < col_dim; j++ ) {
                  ar & value[i][j];
               }
         }

         template<class Archive> void load(Archive & ar, const unsigned int
version) {
            size_t rowdim, coldim;

            ar & rowdim;
            ar & coldim;

            resize( rowdim, coldim );

            for ( size_t i = 0; i < rowdim; i++ )
                for ( size_t j = 0; j < coldim; j++ )
                    ar & value[i][j];
         }

The type of value is T**. The serialization works OK, but I'm getting some
warnings that lead me to suspect that Boost is trying to track the
addresses of the value[i][j] elements, which is not needed, and presumably
a problem for performance.

g++ -c -m64 -O3 -Wall -I../../include
-I/usr/depot/redhatel5_64/boost/1.48.0/include -o
Linux-x86_64/obj/test_Matrix.o test_Matrix.cpp

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/mpl/print.hpp: In
instantiation of
'boost::mpl::print<boost::serialization::BOOST_SERIALIZATION_STATIC_WARNING_LINE<98>
>':

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/serialization/static_warning.hpp:92:
  instantiated from 'boost::serialization::static_warning_test<false, 98>'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/detail/check.hpp:98:
  instantiated from 'void boost::archive::detail::check_object_tracking()
[with T = gcore::Matrix<int>]'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/detail/oserializer.hpp:313:
  instantiated from 'static void
boost::archive::detail::save_non_pointer_type<Archive>::invoke(Archive&,
T&) [with T = gcore::Matrix<int>, Archive = boost::archive::text_oarchive]'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/detail/oserializer.hpp:525:
  instantiated from 'void boost::archive::save(Archive&, T&) [with Archive
= boost::archive::text_oarchive, T = gcore::Matrix<int>]'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/detail/common_oarchive.hpp:69:
  instantiated from 'void
boost::archive::detail::common_oarchive<Archive>::save_override(T&, int)
[with T = gcore::Matrix<int>, Archive = boost::archive::text_oarchive]'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/basic_text_oarchive.hpp:80:
  instantiated from 'void
boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with
T = gcore::Matrix<int>, Archive = boost::archive::text_oarchive]'

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/archive/detail/interface_oarchive.hpp:63:
  instantiated from 'Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T
= gcore::Matrix<int>, Archive = boost::archive::text_oarchive]'

test_Matrix.cpp:43: instantiated from here

/usr/depot/redhatel5_64/boost/1.48.0/include/boost/mpl/print.hpp:55:
warning: comparison between signed and unsigned integer expressions

Is my suspicion correct, and how do I change my code to avoid the warnings
(and performance hits, if any)?

Thanks!

Michele



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net