qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Greg Kurz" <groug@kaod.org>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: 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: Thu, 3 Aug 2017 13:56:45 -0500	[thread overview]
Message-ID: <e11535cd-242f-bfc2-d854-af3cc9044665@redhat.com> (raw)
In-Reply-To: <20170803203805.141d0708@bahia.lan>

[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]

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.

> 
> 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.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2017-08-03 18:56 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 [this message]
2017-08-07 11:13           ` Greg Kurz
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=e11535cd-242f-bfc2-d854-af3cc9044665@redhat.com \
    --to=eblake@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=groug@kaod.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).