-Wmissing-field-initializers warns if a positional initializer does not initialize all fields. However, it does so even if the initializer is {}, which is a common idiom to initialize the entire structure to zero. Please consider not warning in that specific case. If anyone actually *wants* GCC to warn in that case, perhaps that could go in a separate -Wempty-initializer. Alternatively, if people *really* want -Wmissing-field-initializers to warn about {}, could we have some other warning option that only warns about missing field initializers with non-empty initializers?
Wasn't this fixed for C++ recently? Perhaps the code could be shared... In any case, they should behave similarly.
I think it makes sense just not to warn on { }, much as we intentionally don't warn for { 0 }. I'm testing a patch.
In C++ we don't warn for { }. OTOH, C++ warns for { 0 } - I think it should not.
Found it: PR61489 I think warning for {0} is on purpose, since one cannot tell if the struct originally had one field and now it has two. But I don't really agree with it. I think it is too noisy.
The C warning is also nicer than the C++ one because it says where the field is declared. It also only mentions one missing field per declaration, whereas the C++ warning mentions all, which is terribly noisy and repetitive.
Also note PR39589, a request for -Wmissing-field-initializers=2, but it's not as trivial as it seems.
Author: mpolacek Date: Thu Oct 9 08:25:50 2014 New Revision: 216031 URL: https://gcc.gnu.org/viewcvs?rev=216031&root=gcc&view=rev Log: PR c/63480 * c-typeck.c (pop_init_level): Don't warn about initializing with { }. * gcc.dg/pr63480.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr63480.c Modified: trunk/gcc/c/ChangeLog trunk/gcc/c/c-typeck.c trunk/gcc/testsuite/ChangeLog
Fixed.