title: std::string and placement new
body: <p>I found this example of using placement new in C++, and it doesn't make sense to me. 
  It is my view that this code is exception-prone, since more memory than what was allocated may be used. </p>
  
  <pre><code>char *buf  = new char[sizeof(string)];
  string *p = new (buf) string("hi");
  </code></pre>
  
  <p>If "string" is the C++ STD::string class,then buf will get an allocation
  the size of an empty string object (which with my compiler gives 28 bytes),
  and then the way I see it if you initialize your string with more chars you might
  exceed the memory allocated. For example: </p>
  
  <pre><code>string *p = new (buf) string("hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
  </code></pre>
  
  <p>On my VS this seems to be working nevertheless, and I'm not sure if this is because
  the exception is somehow waived or I simply don't understand how string works.</p>
  
  <p>Can someone help clarify?</p>