Opened 7 years ago
Closed 7 years ago
#11612 closed Bugs (invalid)
serializing vector
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.58.0 | Severity: | Problem |
Keywords: | vector | Cc: |
Description
In <boost/serialization/vector.hpp> when dispatching to the default load method and detail::is_default_constructible<U> fails, should the vector be cleared if it is not empty? line 98 reserves capacity for the vector and line 102 pushes new elements into the vector. so if the vector is loaded multiple times its size will grow. if you try to load a vector starting with a vector that is not empty, the vector size will grow.
should you do the following check:
if(!t.empty()) t.clear(); t.reserve(count);
Attachments (1)
Change History (3)
by , 7 years ago
Attachment: | vector.hpp added |
---|
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The code cited is from version 1.58.
Currently we are in version 1.59 and the code has changed in order not to use is_default_constructble.
so this report is not applicable.
also, in my particular context, detail::is_default_constructible<MyClass> is failing when it should not be since MyClass is indeed default constructible. I checked:
std::is_default_constructible<std::vector<MyClass>>::value == true
but
boost::serialization::detail::is_default_constructible<std::vector<MyClass>>::value == false
I also believe that the BOOST_NO_CXX11_HDR_TYPE_TRAITS flag is not being set properly.