------- Comment #1 from pinskia at gcc dot gnu dot org 2006-12-02 08:10 ------- Confirmed. /* Do not warn if this level of the initializer uses member designators; it is likely to be deliberate. */ if (constructor_unfilled_fields && !constructor_designated)
I think we forget to push/pop the context for compound literals. Here is another testcase where we warn: struct foo { char *p; int i; int j; } bar = { .j = 1, .p = (char[]){"abc"} }; And one where we don't as the order of the compound literal has changed: struct foo { char *p; int i; int j; } bar = { .p = (char[]){"abc"}, .j = 1 }; ----- Here is an even more complex testcase where we warn too much: struct h { int x, y; }; struct g { struct h *i; int j; }; struct foo { struct g *v; int i1; int j1; } bar = { &(struct g) { .i = &(struct h){1} } }; ------------------------------------ t.c:16: warning: missing initializer t.c:16: warning: (near initialization for (anonymous).y) t.c:17: warning: missing initializer t.c:17: warning: (near initialization for (anonymous).j) t.c:18: warning: missing initializer t.c:18: warning: (near initialization for bar.i1) We should not warn about (anonymous).j. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 GCC build triplet|i386-portbld-freebsd7.0 | GCC host triplet|i386-portbld-freebsd7.0 | GCC target triplet|i386-portbld-freebsd7.0 | Keywords| |diagnostic Known to fail| |2.95 3.2.3 3.4.0 4.0.0 4.2.0 | |4.0.4 4.1.2 4.2.0 4.3.0 Last reconfirmed|0000-00-00 00:00:00 |2006-12-02 08:10:07 date| | Summary|Compound literal in |Compound literal in |structure initializer causes|structure initializer causes |irrelevant warning |missing initializer warning | |to happen http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30006