Boost logo

Boost Users :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2006-10-26 12:34:12


RIVASSEAU Jean Noel wrote:
> I've had the same problems. The problem is with the bool field. Code
> restoring the archive crashes if the bool stored in the archive is not
> equal to 0 or 1. But since you did not write a constructor in the Obj
> class, the boolean will actually be initialized with anything( eg, read
> 14675002 for example), and will be serialized that way in the archive
> since it seems the serialization code does not check if the bool is
> equal to 0 or 1 (only the restoration code).
>
> So, the solution is to initialize your boolean correctly and be very
> careful whenever you use booleans. However, I think the Serialization
> code should be fixed (remove the check for 0 or 1, it probably does
> more bad than good.
>

In my (very) humble opinion, it should be at least symmetric. So either
no check for 0 or 1 in both directions or a check for 0 or 1 in both
directions.

But it should also be consistent with other built-in types. Since it
appears that there is no check (is one even possible?) for uninitialized
   data with other built-in types, I also vote for no check.


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