This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Another GLIBC build error with GCC6


On Tue, 2015-07-21 at 15:22 -0600, Jeff Law wrote:

> >> Any chance I could get you to file a GCC bug for this bogus warning?
> >>
> >> Jeff
> >
> > Is it bogus?  I never followed the various macros down far enough to see
> > if the references were out of bounds or not.  I will see if I can create
> > a cut-down test case.
> If it's not a false positive, then you're suppressing a warning on code 
> that's got undefined behaviour...  That seems unwise.
> 
> Jeff

Ok, the array out of bound error was due to my change to the
DT_EXTRATAGIDX macro which was invalid.  If I undo that change the array
out of bounds message goes away but I get the shift-overflow messages:

#include <stdint.h>
#include <stdio.h>

int main()
{
 printf("%d\n", 0x7ffffffd);
 printf("%d\n", (0x7ffffffd << 1));
 printf("%d\n", ((0x7ffffffd << 1) >> 1));
}

The latest GCC complains with:

z.c: In function 'main':
z.c:7:29: warning: result of '2147483645 << 1' requires 33 bits to
represent, but 'int' only has 32 bits [-Wshift-overflow=]
  printf("%d\n", (0x7ffffffd << 1));
                             ^
z.c:8:30: warning: result of '2147483645 << 1' requires 33 bits to
represent, but 'int' only has 32 bits [-Wshift-overflow=]
  printf("%d\n", ((0x7ffffffd << 1) >> 1));
                              ^

Would you say that it is a GCC bug to complain about this?  I don't see
any reason why it should complain.  shifting is going to lose some bits
off the end of the constant but isn't that what a shift does?

Steve Ellcey
sellcey@imgtec.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]