Is this a memory leak, if not is it guaranteed by the standard?
<p>Related to a <a href="http://stackoverflow.com/questions/8915963/how-to-calculate-the-length-of-array-using-a-macro-function/8916050#8916050">recent question</a>, I wrote the following code:</p>

<pre><code>int main()
{
   char* x = new char[33];
   int* sz = (int*)x;
   sz--;
   sz--;
   sz--;
   sz--;
   int szn = *sz; //szn is 33 :)
}
</code></pre>

<p>I do know it's not safe and would never use it, but it brings to mind a question:</p>

<p>Is the following safe? Is it a memory leak?</p>

<pre><code>char* allocate()
{
    return new char[20];
}

int main()
{
    char* x = allocate();
    delete[] x;
}
</code></pre>

<p>If it's safe, doesn't that mean we can actually find the size of the array? Granted, not in a standard way, but is the compiler <strong>required</strong> to store information about the size of the array?</p>

<h3>I am not using or plan on using this code. I know it is undefined behavior. I know it isn't guaranteed by anything. It's just a theoretical question!</h3>
