Boost logo

Boost Users :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2005-11-09 13:02:53


I am serialising data structures that include objects of the form:

    std::vector<boost::shared_ptr<MyClass> >

where MyClass contains simple times and further classes.

This would not deserialise correctly in Boost 1.33.0 when in XML format,
and I think there was discussion of there being a bug in deserialisation
of vectors in that version of the serialization library.

The bug persisted with the new version of Boost (not 1.33.1 that has
just been released but a version from the CVS from a few days ago, which
is probably close to or the same as 1.33.1 anyway).

I tracked it down to the serialisation of an uninitialised boolean, to
which Visual Studio .NET 7.1 had given the garbage value 205. The
serialization library generates a stream error when this is read back
into a boolean, naturally enough, because it is not a valid value for a
boolean.

My question is whether the serialization library should be made more
robust to handle uninitialised variables. In the case of all other
variables, of course, it is not easy or not possible to detect in a
simple manner whether or not a variable is initialised: is that integer
meant to have value 1.23456E+66 or is it just uninitialised? For
booleans, though, a value of other than 0 or 1 means it has not been
initialised, and perhaps this should throw an exception on writing to
the archive rather than on reading from it.

If handling uninitialised variables is not practical, then perhaps there
could be a warning in the documentation that uninitialised booleans will
cause stream errors on deserialisation.

Paul


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