Boost logo

Boost Users :

From: Sergey Skorniakov (s.skorniakov_at_[hidden])
Date: 2005-09-01 02:56:12


Following code produced assert at line 444 in
libs/serializatin/src/basic_iarchive with version 1.32.0, 1.33.0 and with
every archive that's headers are included:

#define BOOST_SERIALIZATION_DYN_LINK
#include <boost/archive/polymorphic_iarchive.hpp>
#include <boost/archive/polymorphic_oarchive.hpp>

#include <boost/archive/polymorphic_text_iarchive.hpp>
#include <boost/archive/polymorphic_text_oarchive.hpp>

#include <boost/archive/polymorphic_xml_iarchive.hpp>
#include <boost/archive/polymorphic_xml_oarchive.hpp>

#include <boost/archive/polymorphic_binary_iarchive.hpp>
#include <boost/archive/polymorphic_binary_oarchive.hpp>

#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

#include <iostream>
#include <sstream>
#include <boost/serialization/map.hpp>

int main(int argc, char* argv[])
{
 std::pair<int, int> a(11, 22);
 std::map<int, int> b;
 b[0] = 0;
 b[-1] = -1;
 b[1] = 1;

 std::stringstream ss;
    {
        std::pair<int, int> *pa = &a;
        std::map<int, int> *pb = &b;
        boost::archive::binary_oarchive oa(ss);
        oa << boost::serialization::make_nvp("B1", pb);
        oa << boost::serialization::make_nvp("A1", pa);
    }
    std::cout << ss.str();
    {
        std::pair<int, int> *pa = 0;
        std::map<int, int> *pb = 0;
        boost::archive::binary_iarchive ia(ss);
        ia >> boost::serialization::make_nvp("B1", pb);
        ia >> boost::serialization::make_nvp("A1", pa);
        delete pa;
        delete pb;
    }

 return 0;
}

Similar program without nvp's has the same problem:

int main(int argc, char* argv[])
{
    std::pair<int, int> a(11, 22);
    std::map<int, int> b;
    b[0] = 0;
    b[-1] = -1;
    b[1] = 1;
    std::stringstream ss;
    {
        std::pair<int, int> * const pa = &a;
        std::map<int, int> * const pb = &b;
        boost::archive::text_oarchive oa(ss);
        oa << pb;
        oa << pa;
    }
    std::cout << ss.str();
    {
        std::pair<int, int> *pa = 0;
        std::map<int, int> *pb = 0;
        boost::archive::text_iarchive ia(ss);
        ia >> pb;
        ia >> pa;
        delete pa;
        delete pb;
    }
    return 0;
}


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