https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39589

Matthijs Kooijman <matthijs at stdin dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matthijs at stdin dot nl

--- Comment #11 from Matthijs Kooijman <matthijs at stdin dot nl> ---
It seems this was actually implemented at some point (at least for C++, maybe
that was the case all along already), though the manual page was not updated to
reflect this. Taking the example from the manual (which is documented to *not*
cause this warning):

matthijs@grubby:~$ cat foo.cpp 
struct s { int f, g, h; };
struct s x = { .f = 3, .g = 4 };
matthijs@grubby:~$ gcc foo.cpp -c  -Wall -Wextra
foo.cpp:2:31: warning: missing initializer for member ‘s::h’
[-Wmissing-field-initializers]
 struct s x = { .f = 3, .g = 4 };
                               ^
However, this seems to be the case only for C++, if I rename to foo.c, no
warning is emitted.


I actually came here looking for a way to *disable* this warning for designated
initializers on a specific struct. I was hoping to use a struct with designated
initializers as an elegant way to specify configuration with optional fields
(e.g. by lettin any unspecified fields be initialized to 0 and fill in a
default value for them). However, when any caller that omits a field to get the
default value is pestered with a warning, that approach does not really work
well. On the other hand, disabling the warning completely with a commandline
option or pragma seems heavy-handed, since I do consider this a useful warning
in many other cases.

Reply via email to