qemu-devel
[Top][All Lists]
Advanced

[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: Greg Kurz
Subject: Re: [Qemu-devel] [PATCH] kvm: workaround build break on gcc-7.1.1 / fedora26
Date: Mon, 7 Aug 2017 13:13:09 +0200

On Thu, 3 Aug 2017 13:56:45 -0500
Eric Blake <address@hidden> 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: pgptByJx55OOS.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]