Opened 7 years ago

Closed 7 years ago

#11498 closed Bugs (fixed)

Deserialization of a vector does not delete existing elements

Reported by: pcarnevali@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.58.0 Severity: Showstopper
Keywords: Cc:

Description

Problem deserializing (loading) an std::vector in boost 1.58.0. If the vector is not empty, the existing elements are not removed. The code compiles and serialization completes without errors, but after deserialization the vector has the deserialized vector elements appended after the previously existing elements. This is not the correct and documented behavior. Works fine in boost 1.56.0. See the attached program, which does the following:

  • Creates an object of class B, called b1, containing a vector of 3 objects of class A. Class A does have a public default constructor.
  • The b1 object is serialized (stored) using the boost serialization library.
  • A new object of class B, called b2, is created, and initialized with two elements.
  • Finally, the b2 object is loaded, using serialization, from the archive on which b1 was saved.
  • The program compiles and terminates without errors, but at the end the b2 object contains the initial 2 elements plus the 3 elements loaded from b1, for a total 5 elements.

This is with gcc 4.8.2 on Linux Centos-7.

Attachments (1)

a.cpp (1.2 KB ) - added by pcarnevali@… 7 years ago.

Download all attachments as: .zip

Change History (2)

by pcarnevali@…, 7 years ago

Attachment: a.cpp added

comment:1 by Robert Ramey, 7 years ago

Resolution: fixed
Status: newclosed

fixed changeset 50d5984 4/24/15

Note: See TracTickets for help on using tickets.