title: std::vector reserve method fails to allocate enough memory
body: <p>I have a buffer class in my C++ application as follows:</p>
  
  <pre><code>class Buffer
  {
      public:
      Buffer(size_t res): _rpos(0), _wpos(0)
      {
          _storage.reserve(res);
      }
  
      protected:
      size_t _rpos, _wpos;
      std::vector&lt;uint8&gt; _storage;
  }
  </code></pre>
  
  <p>Sometimes using the constructor fails because its unable to allocate the required memory space. For example, once,  calling the constructor with <code>res = 37</code> caused a segfault with the following stack trace that i got from its core dump:</p>
  
  <pre><code>#0  0x00007f916a176ed5 in raise () from /lib/libc.so.6
  No symbol table info available.
  #1  0x00007f916a1783f3 in abort () from /lib/libc.so.6
  No symbol table info available.
  #2  0x00007f916a1b33a8 in ?? () from /lib/libc.so.6
  No symbol table info available.
  #3  0x00007f916a1b8948 in ?? () from /lib/libc.so.6
  No symbol table info available.
  #4  0x00007f916a1bb17c in ?? () from /lib/libc.so.6
  No symbol table info available.
  #5  0x00007f916a1bca78 in malloc () from /lib/libc.so.6
  No symbol table info available.
  #6  0x00007f916ac0c16d in operator new (sz=37)
      at ../../.././libstdc++-v3/libsupc++/new_op.cc:52
          p = &lt;value optimized out&gt;
  #7  0x00000000004e3d11 in std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;::reserve (this=0x7f911bc49cc0, __n=31077)
      at /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.2/../../../../include/c++/4.4.2/ext/new_allocator.h:89
          __old_size = 0
          __tmp = &lt;value optimized out&gt;
  </code></pre>
  
  <p>I've compiled this application using GCC 4.4.2 as a 64 bit application and I'm using it in Debian 5 x64.</p>
  
  <p>Any help is much appreciated.
  Thanks</p>