<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 6 April 2013 01:02, Walter Bright <span dir="ltr"><<a href="mailto:walter@digitalmars.com" target="_blank">walter@digitalmars.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
On 4/5/2013 3:56 PM, David Nadlinger wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
My point here is that C compiler might not align the same data to 16 bytes.<br>
</blockquote>
<br></div>
Consider the following C code:<br>
------------------------------<u></u>--------<br>
#include <stdio.h><br>
<br>
struct S {<br>
    int a[4];<br>
};<br>
<br>
int x;<br>
struct S s;<br>
<br>
struct T {<br>
    int t;<br>
    struct S s;<br>
};<br>
<br>
void main()<br>
{<br>
    printf("%p %p %d\n", &x, &s, sizeof(struct T));<br>
}<br>
------------------------------<br>
<br>
I compiled it with gcc under Linux. x is aligned to 4 bytes, and s is aligned to 16 bytes (you can see this using dumpobj on the object file). The sizeof(struct T) is also 20 bytes, just like in dmd.<br>
<br>
dmd is behaving just like gcc does.<div class=""><div class="h5"><br clear="all"></div></div></blockquote></div><br></div><div class="gmail_extra">You can also see more in the assembly produced by gcc.<br><br></div><div class="gmail_extra">
32bit:<br>        .comm   x,4,4<br>        .comm   s,16,4<br>---<br></div><div class="gmail_extra">64bit:<br>        .comm   x,4,4<br>        .comm   s,16,16<br></div><div class="gmail_extra"><br><br></div><div class="gmail_extra">
Looks like dmd is behaving just like 64bit gcc does. But not 32bit.<br></div><div class="gmail_extra"><br>-- <br>Iain Buclaw<br><br>*(p < e ? p++ : p) = (c & 0x0f) + '0';
</div></div>