|
Boost : |
Subject: Re: [boost] [Serialization] Bizarre bug
From: Zoran Cvetkov (zoran.cvetkov_at_[hidden])
Date: 2009-08-10 15:19:55
Robert Ramey wrote:
> OK - A2 produces an archive that cannot be read.
> I would argue that including the dummy just to
> provoke this "bug" is just a pathological case and
> basically constitutes an error - albiet a subtle one.
>
> A much more interesting scenario in this vein is the following:
>
> C: Sometime later, the definition of X is changed to
>
> struct X {
> vector<char> * m_pv;
> template<class Archive>
> save(Archive & ar, const unsigned int version) const {
> ar << m_pv;
> }
> template<class Archive>
> load(Archive & ar, const unisgned int version){
> // uh - oh need to support old archives !
> if(version < 1){
> m_pv = new vector<char>()
> ar >> *m_pv
> }
> else
> ar >> m_pv;
> }
> };
>
> BOOST_CLASS_VERSION(X, 1)
>
> This WOULD be a problem and would fail to read
> old archives. I'm willing to consider this a legitimate
> concern.
>
> Still, it's a very infrequent cases.
>
> So in short, I believe that the only way to have such
> a problem is include dummy code which I don't
> consider a huge problem.
>
Both cases alltought maybe not a most common are nevertheless
legitimate. We use extensively serialization framework in our code and
case when someone changes a class data member to be handled with a
shared pointer would not surprise me at all. However the user would be
unaware of the subtility of a such change and a fact that would make old
archives unreadable. Similar situation would be I beleive adding
shared_from_this<T> as a base class - no versioning could help restore
the old archives...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk