Programme crashes while deallocating a character array
<p>When I run the .exe being created with the below code in debug mode , it shows some assertion failure and the programme crashes But when i run the same exe created from the release mode of the below code , its working fine.</p>

<p>Please help to identify why I am geting the assertion failure in debug mode but not in release mode .</p>

<pre><code>#include&lt;iostream&gt;
using namespace std;
#include&lt;string.h&gt;

void main()
{
    char *buf  = new char[5];   //pre-allocated buffer
    buf = "Hello";
    delete [] buf;
    getchar();
    //cout&lt;&lt;buf;
    //string *p = new (buf) string("hi");  //placement new
    //string *q = new string("hi");  //ordinary heap allocation
}
</code></pre>
