This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Aligning struct member has strange impact on struct alignment


Hi all.

I have a strange effect with gcc 3.2.2 on Linux x86, where the C program

#include <stdio.h>
struct S1 { double m; };
struct S2 { double m __attribute__((aligned(4))); };
int main(void) {
    printf(
        "__alignof__(S1) = %d\n__alignof__(S2) = %d\n",
        __alignof__(struct S1), __alignof__(struct S2));
}

prints

__alignof__(S1) = 4
__alignof__(S2) = 8

Why is the alignment of S2 == 8 when I align its double member on 4? Is that a bug, or am I missing something?

-Stephan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]