[dmd-internals] Testcase in test42.d

Iain Buclaw ibuclaw at ubuntu.com
Fri Apr 5 17:49:30 PDT 2013


On 6 April 2013 01:02, Walter Bright <walter at digitalmars.com> wrote:

>
> On 4/5/2013 3:56 PM, David Nadlinger wrote:
>
>>
>> My point here is that C compiler might not align the same data to 16
>> bytes.
>>
>
> Consider the following C code:
> ------------------------------**--------
> #include <stdio.h>
>
> struct S {
>     int a[4];
> };
>
> int x;
> struct S s;
>
> struct T {
>     int t;
>     struct S s;
> };
>
> void main()
> {
>     printf("%p %p %d\n", &x, &s, sizeof(struct T));
> }
> ------------------------------
>
> 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.
>
> dmd is behaving just like gcc does.
>
>
You can also see more in the assembly produced by gcc.

32bit:
        .comm   x,4,4
        .comm   s,16,4
---
64bit:
        .comm   x,4,4
        .comm   s,16,16


Looks like dmd is behaving just like 64bit gcc does. But not 32bit.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20130406/cce5612a/attachment.html>


More information about the dmd-internals mailing list