<p>Say I have the following C++:</p>

<pre><code>char *p = new char[cb];
SOME_STRUCT *pSS = (SOME_STRUCT *) p;
delete pSS;
</code></pre>

<p>Is this safe according to the C++ standard? Do I need to cast back to a <code>char*</code> and then use <code>delete[]</code>? I know it'll work in most C++ compilers, because it's plain-ordinary-data, with no destructors. Is it guaranteed to be safe?</p>

No, it's undefined behaviour - a compiler could plausibly do something different, and as the C++ FAQ entry that
thudbang
linked to says,
```
operator delete[]
```
might be overloaded to do something different to
```
operator delete
```
. You can sometimes get away with it, but it's also good practice to get into the habit of matching delete[] with new[] for the cases where you can't.