qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compil


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers
Date: Fri, 20 Oct 2017 17:44:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 20/10/2017 17:32, Laszlo Ersek wrote:
> On 10/20/17 17:09, Paolo Bonzini wrote:
>> On 20/10/2017 17:08, Laszlo Ersek wrote:
>>> My remark below might matter even less, but:
>>>
>>> I'd find it regrettable if we suppressed a wrong gcc warning about a
>>> valid C construct by replacing the construct with a GNU-ism that is
>>> *not* standard C. :/
>>
>> Is {} to initialize structs a GNUism?
> 
> It is;
> 
>> struct {
>>   int a, b;
>> } x = {};
> 
> $ gcc -fsyntax-only -std=c99 -pedantic -Wall -Wextra x.c
> 
>> x.c:3:7: warning: ISO C forbids empty initializer braces [-Wpedantic]
>>  } x = {};
>>        ^
>> x.c:3:1: warning: missing initializer for field 'a' of 'struct <anonymous>' 
>> [-Wmissing-field-initializers]
>>  } x = {};
>>  ^
>> x.c:2:7: note: 'a' declared here
>>    int a, b;
>>        ^
> 
> If you replace "{}" with "{ 0 }", the same command line stays quiet.
> 
> (I used: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16).)

Oh.  So there _was_ some logic to my original configure patch.
Currently we have 82 occurrences of empty initializers and 92
occurrences of {0}, so I think it makes sense to go ahead with it.

On the other hand, without a more precise option than -Wpedantic, empty
initializers are going to creep in again.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]