[Boost-bugs] [Boost C++ Libraries] #13201: boost::container::small_vector invalid internal capacity

Subject: [Boost-bugs] [Boost C++ Libraries] #13201: boost::container::small_vector invalid internal capacity
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-09 02:29:48


#13201: boost::container::small_vector invalid internal capacity
------------------------------+---------------------------
 Reporter: DirtY.iCE.hu@… | Owner: Ion Gaztañaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
  Version: Boost 1.65.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 Sometimes the internal capacity of the small_vector is smaller than the
 specified. Take the following example:

 {{{
 #include <boost/container/small_vector.hpp>
 #include <iostream>

 int main()
 {
   boost::container::small_vector<char, 15> v{ 0 };
   boost::container::small_vector<char, 15> v2(15);
   std::cout << &v << ' ' << (void*)&v[0] << ' ' << v.capacity() << ' '
             << decltype(v)::static_capacity << '\n';
   std::cout << &v2 << " " << (void*)&v2[0] << ' ' << v2.capacity() << ' '
             << decltype(v2)::static_capacity << '\n';
 }
 }}}

 Output on amd64 linux (with clang 4.0.1, but gcc exhibits the same
 behavior):
 {{{
 0x7ffe053c4700 0x7ffe053c4718 8 15
 0x7ffe053c46c8 0xbbfc20 23 15
 }}}

 On 32-bit (-m32):
 {{{
 0xffdfecb0 0xffdfecbc 12 15
 0xffdfec88 0x86aea10 27 15
 }}}

 Even though the capacity should be 15, it's 8 on 64-bit and 12 on 32-bit,
 while static_capacity reports 15. When actually trying to put 15 elements
 into the vector, it allocates memory from heap.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13201>
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-09-09 02:35:52 UTC