This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Aligning struct member has strange impact on struct alignment
- From: Stephan Bergmann <stephan dot bergmann at sun dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Apr 2004 15:51:36 +0200
- Subject: 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