Re: [Boost-users] [boost.serialization] serialization crash
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Deane Yang Sent: Thursday, October 26, 2006 9:34 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost.serialization] serialization crash
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
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
RIVASSEAU Jean Noel wrote: the archive 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.
In any case, are booleans guaranteed to be 0 or 1 even if correctly initialized?
participants (1)
-
Sohail Somani