http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59741
Bug ID: 59741 Summary: Union with struct with flexible array member output incorrectly Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org I believe this testcase will fail on -fsection-anchors targets (but haven't verified other than eyeballing the assembly): struct A { int a; char b[]; }; union B { struct A a; char b[sizeof (struct A) + 31]; }; union B b = { { 1, "123456789012345678901234567890" } }; union B c = { { 2, "123456789012345678901234567890" } }; __attribute__((noinline, noclone)) void foo (int *x[2]) { x[0] = &b.a.a; x[1] = &c.a.a; } int main () { int *x[2]; foo (x); if (*x[0] != 1 || *x[1] != 2) __builtin_abort (); return 0; } Even on x86_64-linux, one can see bogus assembly: .type c, @object .size c, 36 c: .long 2 .string "123456789012345678901234567890" .zero 32 .globl b .align 16 .type b, @object .size b, 36 b: .long 1 .string "123456789012345678901234567890" .zero 32 (note, .size is correct, but the actual data for the vars much larger than that).