http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58303
Bug ID: 58303 Summary: C99 union initializers new union members clobber earlier data Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: darrenrjenkins at gmail dot com If using C99 initializers on a union, and using different union members. The later members seem to clobber the previous members data. I haven't looked at the standards with respect to this, but it seems wrong. #include <stdio.h> typedef struct { int a; int b; } a_t; typedef struct { int c; int d; } b_t; typedef union { a_t a; b_t b; } c_t; void main( int argc, char *argv[] ) { c_t var = { .a.a = 4, .b.d = 7 }; printf( ".a.a = %d .b.d = %d\n", var.a.a, var.b.d ); }