bad_alloc in std::vector constructor : <p><code>std::vector</code> has a constructor where passing a single argument of <code>size_type count</code> should size the vector with <code>count</code> default-constructed elements. But the following code fails with a <code>bad_alloc</code> exception after a bad conversion:</p>

<pre><code>#include &lt;vector&gt;

struct Inner {
  int foo;
  char buf[256];
};

template &lt;typename Type&gt;
struct Outer
{
  typedef std::vector&lt;Inner&gt; BufContainer;
  typedef typename BufContainer::size_type BufIndex;
  BufContainer bufs1;
  BufContainer bufs2;
  const BufIndex BUFCOUNT = 32;

  Outer() :
    bufs1(32),       // fine
    bufs2(BUFCOUNT)  // bad_alloc
  { }
};

int main() {
  Outer&lt;int&gt; outer;
}
</code></pre>

<p>When I look in the debugger, I can see an incorrect conversion has occurred on that second vector constructor:</p>

<pre><code>#13 0x0000000000400bf1 in Outer&lt;int&gt;::Outer (this=0x7ffdc59570c0) at wtf.cc:22
22          bufs2(BUFCOUNT)
(gdb) down
#12 0x0000000000400d6e in std::vector&lt;Inner, std::allocator&lt;Inner&gt; &gt;::vector     (this=0x7ffdc59570d8, __n=140727918359008, __a=...) at /usr/local/gcc-4.9.1/include/c++/4.9.1/bits/stl_vector.h:278
278       : _Base(__n, __a)
(gdb) list
273        *  This constructor fills the %vector with @a __n default
274        *  constructed elements.
275        */
276       explicit
277       vector(size_type __n, const allocator_type&amp; __a = allocator_type())
278       : _Base(__n, __a)
279       { _M_default_initialize(__n); }
(gdb) print __n
$1 = 140727918359008
</code></pre>

<p><code>std::vector::size_type</code> is simply a typedef from <code>size_t</code>. I don't understand why my defined constant <code>BUFCOUNT</code> results in that rolled-around value inside the constructor, and would appreciate anyone helping me find the obvious thing I'm missing.</p>
