Placement new issue
<p>In this <a href="http://stackoverflow.com/questions/3873625/i-need-c-array-class-template-which-is-fixed-size-stack-based-and-doesnt-req/3873706#3873706">http://stackoverflow.com/questions/3873625/i-need-c-array-class-template-which-is-fixed-size-stack-based-and-doesnt-req/3873706#3873706</a> answer I posted a piece of code, that is using placement new with char array. For me, this is something absolutely normal. But according to comments this code is wrong.</p>

<p>Can anyone explain in more detail?</p>

<p>Specifically what can go wrong with the array. What I understand from the comments is that <code>T x[size];</code> might not fit into <code>char x[size*sizeof(T)];</code>. I don't believe this is true.</p>

<p>EDIT:</p>

<p>I'm just more and more confused. I know what alignment is in case of structures. Yes, when you have a structure the attributes start on different offsets then you might think.</p>

<p>OK, now we are back to arrays. You are telling me that <code>T x[size];</code> is the same size as <code>char x[size*sizeof(T)];</code>, yet I cannot access the char array as T array because there might be some alignment. How can there be alignment when the arrays have the same size?</p>

<p>EDIT 2:</p>

<p>OK I finally get it, it may start on a wrong address.</p>

<p>EDIT 3:</p>

<p>Thx everyone, you can stop posting :-) Phew, this total blew my mind. I just never realized this was possible.</p>
