[Boost-bugs] [Boost C++ Libraries] #6850: serialization/deserialization does not work for more than 25 objects (very strange!!!)

Subject: [Boost-bugs] [Boost C++ Libraries] #6850: serialization/deserialization does not work for more than 25 objects (very strange!!!)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-01 11:30:47


#6850: serialization/deserialization does not work for more than 25 objects (very
strange!!!)
-------------------------------------------------+--------------------------
 Reporter: Liviu <liviu_c_dorobantu@…> | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: serialization deserialization 25 |
-------------------------------------------------+--------------------------
 hello

 I have installed boost 1.47.0 library on my system and I have a strange
 problem. If I try to serialize more then 25 objects, the serialization
 (save()) apparently works but the deserialization (load()) does not work
 anymore and it gives me the following error:

 Unhandled exception at 0x7c812afb in Boost_tests.exe: Microsoft C++
 exception: boost::archive::archive_exception at memory location
 0x0012e5ec..

 this error is raised when the last object (say the 26th object, if the
 number of objects is higher then 25) is being deserialized.

 here is the code:




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

 #include <boost/archive/binary_iarchive.hpp>

 #include <boost/serialization/string.hpp>

 #include <iostream>

 #include <string>

 #include <fstream>

 #include <vector>

 using namespace std;

 #define COUNT 26


 class person;

 vector<person> v;

 class person

 {

 public:

 string _name;

 int _age;

 person (string name="Liviu", int age=25):_name(name),_age(age){};

 friend class boost::serialization::access;


 template <typename Archive>

 void serialize(Archive & ar, const unsigned int version)

 {

 ar & _name;

 ar & _age;

 }

 };


 void save()

 {

 ofstream file("archiv.cst");

 boost::archive::binary_oarchive oa(file);


 for (int i=1; i<=COUNT; i++)

 {

 oa<<person("John",i);

 }

 file.close();

 };

 void load()

 {

 ifstream file("archiv.cst");

 boost::archive::binary_iarchive ia(file);


 for (int i=1; i<=COUNT; i++)

 {

 person p;

 ia>>p;

 v.push_back(p);


 // cout << p._name<<" " <<p._age<<endl;

 }

 file.close();

 };


 int main()

 {

 int i;

 cin>>i;

 while (i!=2)

 {

 if (i==0) save();

 if (i==1) load();

 cin>>i;

 }

 }

 }}}





 Can you help me please? Is something wrong with the library?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6850>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC