|
Boost Users : |
Subject: [Boost-users] [ptr_container] ptr_vector and ptr_circullar_buffer don't initialize PODs
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-10-29 11:36:41
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 opened a trac ticket (https://svn.boost.org/trac/boost/ticket/3579) and
attached a patch to it.
Roman Perepelitsa.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net