From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-06-27 01:08:33
David Abrahams wrote:
> Joaqu?n M? L?pez Mu?oz <joaquin_at_[hidden]> writes:
>> The new rule introduced in Boost.Serialization that forbids saving
>> of non-const objects has proved a little controversial. My point of
>> view is that the rule, albeit far from perfect, provides some
>> level of safety against hard to track errors. Others' opinions differ.
>> The current rule is a rough approximation to what IMHO would
>> constitute the right enforcement: everytime a trackable object
>> is saved, check wether an object with the same address has been
>> previously saved and, if so, make sure that the object didn't change.
> I don't understand what bugs this is going to catch. Certainly in
> this case,
> for( ...
> X x(... );
> ar << x;
> the low-level problem isn't that x is changing, but that it's a
> different object each time. Two temporally different x's might well
> be identical.
> But all of this misses the high-level problem: the author of the code
> doesn't know what he's doing. You simply can't serialize objects from
> distinct scopes with tracking into the same archive, because there may
> be aliasing.
Now the key question. Why do I need the tracking if I never save an object
with the same address both by pointer and by value. I don't. In some other
part of program, I might be serializing vector<X*>, but as long as none of
those pointers point to stack objects, I don't need tracking in the above
And serialization library insist on tracking just because somewhere else in
the program pointer to X is serialized.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk