-Wmissing-field-initializers got shot in the leg

Georg GCC User georggcc@googlemail.com
Fri Dec 30 09:26:00 GMT 2016


Hi,

-Wmissing-field-initializers is documented to do what its name
suggests, i.e. warn about missing initialisers for members,
but only provided that the programmer does *not* specify
designators for members of a struct, say. Thus, in C,

struct R {
  int a;
  int b;
  int newField; /* added at a later stage. */
};

and then given an initialiser placed some time before the addition
of .newField, somewhere else,

  struct R test = (struct R) {
   .a = 42,
   .b = -1
  };

passes without warning, as documented. This can cause
the programmer to manually scan all uses of struct R for possibly
missing initialisation.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
looks light it might be causing this behaviour.

I understand that the relaxation request of #36750 was inspired
by C++ {} initialisation, as well as the 0 case. But from a software
development point of view (as in longer development process, teams, etc.),
this behaviour of suppressing warnings is disturbing.
And I don't want to drop designators just because omitting
them and loosing information will make GCC warn again.
Imagine larger structures.

Is there some other way to make GCC warn, or will a change request
be in order?

Georg



More information about the Gcc-help mailing list