http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023
Bug #: 52023 Summary: _Alignof (double) yields wrong value on x86 Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: egg...@gnu.org Host: x86-64 Target: x86 Build: x86-64 Created attachment 26482 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26482 gcc -v output On x86, alignof (double) should be 4, since that's the alignment requirement used for 'double' when laying out structures. But with GCC alignof incorrectly returns 8. This causes some gnulib tests to fail and (more importantly) it may cause problems with programs such as conservative garbage collectors that use alignof to determine which addresses might be of valid objects. The problem also occurs with other fundamental types, such as 'long long'. Here's a simple test case: #include <stddef.h> #include <stdalign.h> int a = alignof (double); int b = offsetof (struct { char c; double d; }, d); int main (void) { return a == b; } Here's the preprocessed output: int a = _Alignof (double); int b = __builtin_offsetof (struct { char c; double d; }, d); int main (void) { return a == b; } 'main' should return 1, but it returns 0 due to the bug, which causes 'a' to be 8 instead of 4 as it should be. I'm using GCC on the trunk (r183603), built on Fedora 16 x86-64 with no special flags, and I'm compiling with 'gcc -v -m32 test.c' and running with './a.out'. I'm attaching the output of 'gcc -v'.