|
Boost Users : |
From: Andrew B (andrewfb_at_[hidden])
Date: 2005-04-04 20:02:51
Let me first say "thanks" to everyone involved in Boost, particularly
the serialization library. I am continuously impressed with the
quality of this project.
That said, I think I've encountered an issue that I would label as a
bug, but perhaps there's something I'm missing.
The following code throws/fails in Visual C++ 7.1 debug build.
void boolTest()
{
bool uninitializedBool1, uninitializedBool2;
std::ofstream ofs( "booltest.txt" );
boost::archive::text_oarchive oa( ofs, boost::archive::no_header );
oa << uninitializedBool1;
oa << uninitializedBool2;
ofs.close();
std::ifstream ifs( "booltest.txt" );
boost::archive::text_iarchive ia( ifs, boost::archive::no_header );
ia >> uninitializedBool1;
ia >> uninitializedBool2;
ifs.close();
}
The reason is clear if you look at the contents of booltest.txt:
204 204
Since those bools are uninitialized, VC has written its standard
"garbage" to their contents, which gets serialized as a value other
than 0 or 1, which is what what the text_iarchive / ifstream would
expect to see. I'm not sure if there's a philosophical opposition to
supporting serializing uninitialized data, but the other primitives
seem to work, and in my experience, it's not unusual to not initialize
ever member of a struct before needing to serialize it.
Thanks for your time,
Andrew
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