On 22 Feb 2016, at 10:56, David Chisnall <thera...@freebsd.org> wrote: > > On 19 Feb 2016, at 23:23, Dimitry Andric <d...@freebsd.org> wrote: >> >> This warning is only produced when you use -Wall -W, and then initialize >> structs partially, i.e. you initialize some fields but not others. I >> think this is a quite reasonable warning for a high warning level. > > The warning is annoying in many ways. You ought to be able to zero > initialise any struct with {0}, but clang objects if you do this and requires > every field to be filled in. This warning really shouldn’t be enabled with > -Wall, because it has too hight a false positive rate.
It isn't, it is in -W (a.k.a -Wextra). But gcc also warns in this case. E.g. if I use this example: struct foo { int i; int j; } bar[] = { { 42 }, { 43 } }; I get the following warnings from gcc -Wextra: $ gcc -Wextra -c initializers.c initializers.c:5:2: warning: missing initializer for field 'j' of 'struct foo' [-Wmissing-field-initializers] { 42 }, ^ initializers.c:3:6: note: 'j' declared here int j; ^ initializers.c:6:2: warning: missing initializer for field 'j' of 'struct foo' [-Wmissing-field-initializers] { 43 } ^ initializers.c:3:6: note: 'j' declared here int j; ^ Note that the warnings disappear if C99 initializers are used. -Dimitry
signature.asc
Description: Message signed with OpenPGP using GPGMail