This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Another GLIBC build error with GCC6
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 21 Jul 2015 15:36:37 -0700
- Subject: Re: Another GLIBC build error with GCC6
- Authentication-results: sourceware.org; auth=none
- References: <1437496279 dot 19674 dot 126 dot camel at ubuntu-sellcey> <1437507995 dot 19674 dot 136 dot camel at ubuntu-sellcey> <55AEA71B dot 2020405 at redhat dot com> <1437509796 dot 19674 dot 138 dot camel at ubuntu-sellcey> <55AEB7FF dot 1000405 at redhat dot com>
- Reply-to: <sellcey at imgtec dot com>
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