extern void abort (void); typedef int T __attribute__((aligned)); struct S { T a[2]; } s; void *p[2];
int main (void) { p[0] = &s.a[0]; p[1] = &s.a[1]; if (p[0] == p[1]) abort (); return 0; } is miscompiled on at least i386, x86_64, ppc32 and ppc64, at all optimization levels. Works correctly in C++. -- Summary: [4.0/4.1 Regression] Miscompilation with __attribute ((aligned)) Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20794