http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57180
Bug #: 57180 Summary: Structures with a flexible arrray member have wrong size Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: amo...@gmail.com CC: algr...@acm.org, amo...@gmail.com, fredrickprasha...@gmail.com, gcc-bugs@gcc.gnu.org, lauro.venan...@gmail.com, qrc...@knm.org.pl, sbsid...@gmail.com Depends on: 28865 +++ This bug was initially created as a clone of Bug #28865 +++ Cloned from 28865, because the problem is more than just getting .size wrong. The following testcase fails on all targets at all optimization levels. The testcase was taken from glibc/nss/nss_files/files-init.c, which is miscompiled on powerpc or any other target using -fsection-anchors. union { struct { long j; char c[]; } s; char pad[32]; } x[2] = { { .s = { .c = "abc123" } }, { .s = { .c = "xyz" } } }; int main (void) { if (sizeof (x[0]) != 32) __builtin_abort (); if (x[1].s.c[0] != 'x') __builtin_abort (); return 0; }