Boost C++ Libraries: Ticket #13201: boost::container::small_vector invalid internal capacity https://svn.boost.org/trac10/ticket/13201 <p> Sometimes the internal capacity of the small_vector is smaller than the specified. Take the following example: </p> <pre class="wiki">#include &lt;boost/container/small_vector.hpp&gt; #include &lt;iostream&gt; int main() { boost::container::small_vector&lt;char, 15&gt; v{ 0 }; boost::container::small_vector&lt;char, 15&gt; v2(15); std::cout &lt;&lt; &amp;v &lt;&lt; ' ' &lt;&lt; (void*)&amp;v[0] &lt;&lt; ' ' &lt;&lt; v.capacity() &lt;&lt; ' ' &lt;&lt; decltype(v)::static_capacity &lt;&lt; '\n'; std::cout &lt;&lt; &amp;v2 &lt;&lt; " " &lt;&lt; (void*)&amp;v2[0] &lt;&lt; ' ' &lt;&lt; v2.capacity() &lt;&lt; ' ' &lt;&lt; decltype(v2)::static_capacity &lt;&lt; '\n'; } </pre><p> Output on amd64 linux (with clang 4.0.1, but gcc exhibits the same behavior): </p> <pre class="wiki">0x7ffe053c4700 0x7ffe053c4718 8 15 0x7ffe053c46c8 0xbbfc20 23 15 </pre><p> On 32-bit (-m32): </p> <pre class="wiki">0xffdfecb0 0xffdfecbc 12 15 0xffdfec88 0x86aea10 27 15 </pre><p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13201 Trac 1.4.3