#3579 closed Bugs (fixed)
[ptr_container] ptr_vector<T>::resize creates uninitialized objects if T is a POD
Reported by: | Owned by: | Thorsten Ottosen | |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | ptr_container |
Version: | Boost 1.40.0 | Severity: | Problem |
Keywords: | ptr_container, ptr_vector | Cc: | roman.perepelitsa@… |
Description
ptr_vector<T>::resize creates new objects using 'new T' instead of 'new T()', which results in uninitialized objects if T is a POD. For consistency with STL containers (std::vector in particular) all PODs must be explicitly initialized.
Test: #include <cassert>
#include <boost/ptr_container/ptr_vector.hpp>
int main() {
boost::ptr_vector<int> v;
v.resize(1);
assert(v[0] == 0); Might fail.
}
ptr_circullar_buffer has the same problem.
I'm attaching a patch that fixes the problem.
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | ptr_container.diff added |
---|
comment:1 by , 13 years ago
Component: | None → ptr_container |
---|---|
Owner: | set to |
comment:2 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch applied to trunk.
Thanks
-Thorsten
comment:4 by , 9 years ago
class boost::ptr_vector<XXX, boost::heap_clone_allocator, std::allocator<void*> >' has no member named 'resize'
Patch with the fix