http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47557

Jeffrey Yasskin <jyasskin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jyasskin at gcc dot gnu.org

--- Comment #3 from Jeffrey Yasskin <jyasskin at gcc dot gnu.org> 2011-03-15 
18:18:06 UTC ---
Alignments on typedefs behave very strangely (PR48138). What you want is:

typedef struct __attribute__((aligned(2))) {
    char a[3];
} T;

unsigned x1 = sizeof(T);        // sizeof is 4
unsigned x2 = sizeof(T[1]);     // sizeof is 4
unsigned x3 = sizeof(T[2]);     // sizeof is 8
unsigned x4 = sizeof(T[2][1]);  // sizeof is 8
unsigned x5 = sizeof(T[1][2]);  // sizeof is 8

Moving the attribute makes it apply to the struct instead of the typedef, which
fixes everything. C1x and C++0x don't allow alignments on typedefs either.

Reply via email to