http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52769
Bug #: 52769 Summary: Unspecified designated initializer might not set to zero in some cases Classification: Unclassified Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: hud...@osresearch.net #include <stdio.h> typedef struct { int should_be_zero; char s[6]; int x; } foo_t; int main(void) { const foo_t foo = { .s = "123456", .x = 2 }; if (foo.should_be_zero != 0) printf("FAIL: %p val=%d\n", &foo, foo.should_be_zero); return 0; } If s is not fully filled (with room for the terminating nul), the test passes. If x is not set in the designated initializer, the test passes. Fails gcc-4.4.1 with both -m32 and -m64: gcc-4.4 -m64 -std=c99 -O3 initializer-bug.c && ./a.out FAIL: 0x7fffaf867950 val=-1350141376 gcc-4.4 -m32 -std=c99 -O3 initializer-bug.c && ./a.out FAIL: 0xffc7df90 val=-144136635 Also fails with 4.3.4, but passes with 4.2.4.