[Boost-bugs] [Boost C++ Libraries] #3579: [ptr_container] ptr_vector<T>::resize creates uninitialized objects if T is a POD

Subject: [Boost-bugs] [Boost C++ Libraries] #3579: [ptr_container] ptr_vector<T>::resize creates uninitialized objects if T is a POD
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-10-29 15:31:46


#3579: [ptr_container] ptr_vector<T>::resize creates uninitialized objects if T is
a POD
-----------------------------------------+----------------------------------
 Reporter: roman.perepelitsa@… | Owner:
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: None
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: ptr_container, ptr_vector |
-----------------------------------------+----------------------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3579>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC