qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, lersek@redhat.com
Subject: [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers
Date: Fri, 20 Oct 2017 12:12:19 +0200	[thread overview]
Message-ID: <20171020101219.2378-1-pbonzini@redhat.com> (raw)

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 <pbonzini@redhat.com>
---
        Of course it's always possible to use "memset", but {0}
        is neater in my opinion.

 configure | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/configure b/configure
index 7766e74125..0b2d595c6e 100755
--- a/configure
+++ b/configure
@@ -1651,6 +1651,19 @@ EOF
   fi
 fi
 
+# Disable -Wmissing-braces on older compilers that warn even for
+# the "universal" C zero initializer {0}.
+cat > $TMPC << EOF
+struct {
+  int a[2];
+} x = {0};
+EOF
+if compile_object "-Werror" "" ; then
+  :
+else
+  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
+fi
+
 # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
 # large functions that use global variables.  The bug is in all releases of
 # GCC, but it became particularly acute in 4.6.x and 4.7.x.  It is fixed in
-- 
2.14.2

             reply	other threads:[~2017-10-20 10:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 10:12 Paolo Bonzini [this message]
2017-10-20 10:27 ` [Qemu-devel] [PATCH] build: disable -Wmissing-braces on older compilers 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

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=20171020101219.2378-1-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lersek@redhat.com \
    --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).