[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedo
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26 |
Date: |
Thu, 3 Aug 2017 13:56:45 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
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
signature.asc
Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26, Greg Kurz, 2017/08/03
Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26, Philippe Mathieu-Daudé, 2017/08/03
Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26, Greg Kurz, 2017/08/03