Boost logo

Boost :

Subject: Re: [boost] [Serialization] Bizarre bug
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-08-11 13:17:52


Jeffrey Bosboom wrote:
> Robert Ramey wrote:

>> The problem only occurs when program 1 contains only
>>
>> ar << T
>>
>> and program 2 contains
>>
>> ar >> T
>> and
>> ar >> Tptr
>>
>> But if only program 2 contains ar >> Tptr - how does the
>> archive it's supposed to read get created? It can be only
>> created by a program which also contains ar << Tptr. That
>> is in order for serialization to make any sense at all both
>> programs have to contain exactly the same sequence of
>> loads and saves. Hence. they will both either serializations
>> for the same set of types at compiler time.
>
> I've been following this discussion, but now I'm a bit confused.
>
> If program A contains ar << T and program B contains ar << Tptr, can
> program C read from files produced by both programs A and B? (C would
> thus require ar >> T in the code that reads files produced by A and ar
>>> Tptr when reading files produced by B.)

The implementation of ar >> Tptr requires the usage of ar >> T by
the library. So ar >> T is always there.

Program A contains only
ar << T
Proram B contains only
ar << Tptr (which implies ar << T as well)

Program C is designed to read both input from program A
as well as program B. So it must contain both:

ar >> T and ar >> Tptr

> I certainly think it "ought to", but as I understand it from the
> discussion, only the files produced by program B would be readable by
> program C.

LOL - dammit- looks like your correct. All this time to get a
good example. So your example would look like

for T = vector<char> or some other collection of primitives

struct X {
    ...
    ar << T
}
struct Y {
    ..
    ar << Tptr
}
Program A
    ar << x; // only x serialized - struct Y not included in program
Program B
    ar << y;
Program C
    ar >> y; // OK
    ar >> x ;// error ! - can't read archive produced by Program A.
    // if x was produced by program B - then no problem

So a good argument for at least including the compile time warning.
Very astute.

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk