From: Greg Kurz <groug@kaod.org>
To: Eric Blake <eblake@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26
Date: Mon, 7 Aug 2017 13:13:09 +0200 [thread overview]
Message-ID: <20170807131309.6261ddfc@bahia.lan> (raw)
In-Reply-To: <e11535cd-242f-bfc2-d854-af3cc9044665@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]
On Thu, 3 Aug 2017 13:56:45 -0500
Eric Blake <eblake@redhat.com> wrote:
> On 08/03/2017 01:38 PM, Greg Kurz wrote:
> > The following code snippet spits a warning with gcc-7.1.1-3.fc26 and -Wall on
> > ppc64le AND x86_64:
> >
> > int foo(void)
> > {
> > char empty_array[] = { };
> > int i, ret = 0;
> >
> > for (i = 0; i < (int) (sizeof(empty_array) / sizeof(empty_array[0])); i++) {
> > ret = empty_array[i];
> > }
> >
> > return ret;
> > }
>
> Confirmed. No idea why the cast makes gcc think i is uninitialized.
>
FYI, I've created a BZ to track this issue in gcc:
https://bugzilla.redhat.com/show_bug.cgi?id=1478864
> >
> > If I drop the (int), the warning goes away... and so does the build break
> > of qemu-system-ppc64 on my ppc64le host.
> >
> > I don't have 4.7.1 or 4.6 compilers around but I could check 4.8.5
> > is okay with that change FWIW.
>
> I tested with gcc 4.4.7 on RHEL 6, but -Wtype-limits there didn't warn
> whether or not the (int) was present; it's possible that we still need
> to test with 4.6 or 4.7.1 to see whether it makes a difference.
>
> >
> >> Ok so let's stop losing time about compiler incoherent warnings, using
> >> -Wno-type-limits for GCC < 5...
> >> So we can keep a sane/understandable codebase, using size_t and no (int)
> >> cast.
>
> That's also a possibility, if we still hit old compilers that require
> the (int).
>
> >>
> >
> > If I also convert 'int i' to 'size_t i' then I get the same error as
> > in commit 61c7bbd2:
> >
> > error: comparison of unsigned expression < 0 is always
> > false [-Werror=type-limits]
>
> Confirmed with newer gcc, whether or not the (int) cast is present.
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-08-07 11:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 14:47 [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26 Greg Kurz
2017-08-03 13:34 ` Philippe Mathieu-Daudé
2017-08-03 13:55 ` Eric Blake
2017-08-03 14:07 ` Philippe Mathieu-Daudé
2017-08-03 18:38 ` Greg Kurz
2017-08-03 18:56 ` Eric Blake
2017-08-07 11:13 ` Greg Kurz [this message]
2017-08-03 14:31 ` Greg Kurz
2017-08-03 13:46 ` Philippe Mathieu-Daudé
2017-08-03 14:10 ` Eric Blake
2017-08-03 14:24 ` Cornelia Huck
2017-08-04 16:54 ` Paolo Bonzini
2017-08-03 14:36 ` Greg Kurz
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=20170807131309.6261ddfc@bahia.lan \
--to=groug@kaod.org \
--cc=cohuck@redhat.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@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).