Boost logo

Boost :

From: Vyacheslav E. Andrejev (vandrejev_at_[hidden])
Date: 2004-11-09 05:53:15


Hello All,

Seriaization library relies on argument dependent lookup (ADL) in calling load and save functions in boost::serialization::free_loader::invoke and boost::serialization::free_saver::invoke accordingly. Library supposes that this feature works well in VC 7.1 (that is macro BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP is undefined). But as I see, first, this supposition is implemented with error, and, second, ADL not always works very well in VC 7.1.

Let's look to file /boost/serialization/split_free.hpp:

namespace serialization {

#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
template<class Archive, class T>
void save(Archive &ar, const T & t, const unsigned int);
template<class Archive, class T>
void load(Archive &ar, T & t, const unsigned int);
#endif

...

Pay attention to "!" sign before BOOST_WORKAROUND. So, if VC version is 7.1 or higher, compiler expects that save and load would be defined in serialization namespace, if VC version is 7.0 or lower, compiler will search those namespaces from which Archive or T are originated. Very well. But let's take a look now to /boost/serialization/set.hpp for example:

#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace boost { namespace serialization {
#else
namespace STD {
#endif

template<class Archive, class Key, class Compare, class Allocator >
inline void save(
    Archive & ar,
    const STD::set<Key, Compare, Allocator> &t,
    const unsigned int /* file_version */
){
...
}

template<class Archive, class Key, class Compare, class Allocator >
inline void load(
    Archive & ar,
    STD::set<Key, Compare, Allocator> &t,
    const unsigned int /* file_version */
){
...
}

In this file if BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP is defined save and load will be defined in serialization namespace, otherwise in the std namespace. But BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP is undefined for VC 7.1 (see /boost/config/compiler/visualc.hpp)! So in VC 7.1, accordingly to split_free.hpp, compiler expects save and load from serialization workspace, but they are defind in std accordingly to set.hpp (and all others stanard containers serialization files). By happy concourse of circumstances, this error is bypassed by errors in compiler and in most casses VC 7.1 compiles serialization library very well. But sometimes it accedentally rembers what ADL is and emits error during link stage that serialization::save and serialization::load are undefined.

I suggest:

1) define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP for VC 7.1 since as I can see Koening search technique implementation is unstable;
2) change "#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)" in split_free.hpp to "#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)".

-- 
Vyacheslav E. Andrejev
System Architect, Excelsior, LLC

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk