svn commit: r295768 - head/usr.sbin/iostat
Dimitry Andric
dim at FreeBSD.org
Mon Feb 22 22:58:02 UTC 2016
On 22 Feb 2016, at 10:56, David Chisnall <theraven at FreeBSD.org> wrote:
>
> On 19 Feb 2016, at 23:23, Dimitry Andric <dim at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20160222/2aa8a848/attachment.sig>
More information about the svn-src-all
mailing list