On 10/20/17 12:12, Paolo Bonzini wrote: > GCC 4.9 and newer stopped warning for missing braces around the > "universal" C zero initializer {0}. One such initializer sneaked
s/sneaked/snuck/ Hmmm, no, wait, both forms are valid! https://en.wiktionary.org/wiki/sneaked https://en.wiktionary.org/wiki/snuck The irregular form snuck originated by analogy with struck for the past of strike. Snuck was originally limited to a few dialects, but is now very widespread (especially in American English) and is recognized by most dictionaries. The word is now one of the best examples of irregularization of a regular verb, along with dove. > 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 <pbonz...@redhat.com> > --- > Of course it's always possible to use "memset", but {0} > is neater in my opinion. Strongly agree. > > 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 Is this an established idiom for the configure script, in place of: if ! compile_object "-Werror" "" ; then ? Looks good to me otherwise. Thanks! Laszlo > + 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 >