|
Boost : |
Subject: [boost] [Serialization] Bizarre bug
From: Jarl Lindrud (jarl.lindrud_at_[hidden])
Date: 2009-08-02 21:53:06
There is a rather bizarre bug in Boost.Serialization, that was reported on this
list three years ago:
http://article.gmane.org/gmane.comp.lib.boost.devel/147010/match=serialization
+bizarre+bug
To sum up, a piece of code that is never even executed, is causing a
serialization error in a different part of the program.
Unfortunately it seems that this bug was never fixed - I just tried it on Boost
1.39.0, and the bug is still there.
Any chance something can be done about it?
For reference, here is the sample program that reproduces the issue:
#include <sstream>
#include <string>
#include <vector>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
template<typename Archive>
struct X
{
template<typename T>
void operator<<(const T &t)
{
Archive &archive = (*(Archive *) NULL);
archive << t;
}
};
void dummy()
{
typedef boost::archive::text_oarchive Archive;
X<Archive> &x = * (X<Archive> *) NULL;
std::vector<char> *pt = NULL;
// uncomment this line to cause the test in main() to fail
//x << pt;
}
int main(int argc, char* argv[])
{
std::vector<char> v0(25, '%');
std::vector<char> v1;
std::ostringstream ostr;
boost::archive::text_oarchive(ostr) & v0;
std::istringstream istr(ostr.str());
boost::archive::text_iarchive(istr) & v1;
bool ok = (v0 == v1);
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk