title: Access the element out of size in C++ vector
body: <p>Today I try something like this in VS2012 and Max OS 10.7</p>
  
  <pre><code>    vector&lt;int&gt; vec;
      vector&lt;int&gt; vec2;
      for(int i = 0;i &lt; 100 ;i++){
          vec.push_back(i);
      }
  
      cout &lt;&lt; "size: " &lt;&lt; vec.size() &lt;&lt; endl;
      cout &lt;&lt; "capacity: " &lt;&lt; vec.capacity() &lt;&lt; endl;
      cout &lt;&lt; vec[127] &lt;&lt; endl;
      //vec2.reserve(10);
      fill_n(vec.begin(),128,-1);
      cout &lt;&lt; vec[127] &lt;&lt; endl;
      return 0;
  </code></pre>
  
  <p>as we know the size of vector is the real number of elements in the container, the code above can cause runtime error in VS2012, but it works fine on Max OS, and I try it in <a href="http://ideone.com/" rel="nofollow">Ideone.com</a> and also run successfully, I am not sure if something wrong with the definition of size and capacity, why I can access element out of size?</p>
  
  <p>PS: the capacity at this situation on my computer is 141 on VS2012 and 128 on Mac OS and Ideone.com</p>