From: Paolo Bonzini <pbonzini@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers
Date: Fri, 20 Oct 2017 17:44:13 +0200 [thread overview]
Message-ID: <fc9827f0-e041-fb31-a77a-f4ed78a635a9@redhat.com> (raw)
In-Reply-To: <f0573dbb-c81e-c3c3-b0a6-8bafc9d0b2ac@redhat.com>
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
prev parent reply other threads:[~2017-10-20 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 10:12 [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers Paolo Bonzini
2017-10-20 10:27 ` Laszlo Ersek
2017-10-20 10:37 ` Paolo Bonzini
2017-10-20 10:45 ` Laszlo Ersek
2017-10-20 10:48 ` Peter Maydell
2017-10-20 11:02 ` Paolo Bonzini
2017-10-20 15:08 ` Laszlo Ersek
2017-10-20 15:09 ` Paolo Bonzini
2017-10-20 15:32 ` Laszlo Ersek
2017-10-20 15:44 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc9827f0-e041-fb31-a77a-f4ed78a635a9@redhat.com \
--to=pbonzini@redhat.com \
--cc=lersek@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).