AnsweredAssumed Answered

Alignment bug (?) in AMD's compiler (with testcase)

Question asked by eudoxos on Feb 2, 2012
Latest reply on Feb 2, 2012 by MicahVillmow

AMD's compiler does not respect alignment of types within unions. Within the struct

struct Foo{

    int c;

    union{ double b0; } b;

};

b0 does not have natural alignment (8 bytes). The Intel/nVidia compilers (LLVM) as well as gcc (all tested versions, as host compiler filling the buffer with data) aligns b0 properly. I am attaching test file which demonstrates the difference.

 

Dumping the part of the memory, I obtain with AMD:

b0 is at 4

b0 : ad 49 b2 d4 01 22 c6 c6

foo: 7d c3 94 25 ad 49 b2 d4   01 22 c6 c6

whereas with Intel/nVidia:

b0 is at 8

b0 : 01 22 c6 c6 21 ea b1 d4

foo: 7d c3 94 25 ad 49 b2 d4   01 22 c6 c6 21 ea b1 d4

Attachments

Outcomes