[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compil
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers |
Date: |
Fri, 20 Oct 2017 17:08:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 10/20/17 13:02, Paolo Bonzini wrote:
> On 20/10/2017 12:48, Peter Maydell wrote:
>> On 20 October 2017 at 11:12, Paolo Bonzini <address@hidden> wrote:
>>> GCC 4.9 and newer stopped warning for missing braces around the
>>> "universal" C zero initializer {0}. One such initializer sneaked
>>> into scsi/qemu-pr-helper.c and is breaking the build with such
>>> older GCC versions.
>>>
>>> Detect the lack of support for the idiom, and disable the warning
>>> in that case.
>>>
>>> Signed-off-by: Paolo Bonzini <address@hidden>
>>
>> AFAIK "{}" will work and not be warned about anywhere (we
>> use it extensively already) so you don't need to fall back to
>> memset...
>
> Doh, of course that will work in scsi/qemu-pr-helper.c. In general you
> can use {0} but not {} to initialize a scalar, like
>
> IDontKnowIfItsAnArrayOrPointer x = {}; //might fail
> IDontKnowIfItsAnArrayOrPointer x = {0}; //always works
>
> I'm not sure if that matters.
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. :/
Laszlo