This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Another GLIBC build error with GCC6
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 21 Jul 2015 09:31:19 -0700
- Subject: Another GLIBC build error with GCC6
- Authentication-results: sourceware.org; auth=none
- References: <201507211626 dot t6LGQrjm046462 at rly03d dot srv dot mailcontrol dot com>
- Reply-to: <sellcey at imgtec dot com>
I just ran into this problem when compiling string/strchr in ILP32 mode
on MIPS:
strchr.c: In function strchr:
strchr.c:66:40: error: result of 2130640638l << 16 requires 48 bits to represent, but long int only has 32 bits [-Werror=shift-overflow=]
case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
^
strchr.c:66:47: error: result of -16908288l << 16 requires 42 bits to represent, but long int only has 32 bits [-Werror=shift-overflow=]
case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
It looks like it is due to some GCC changes involving -Wshift-overflow
(PR c++/55095)
Here is a cut-down test case that gives the warning with the latest GCC in
32 bit mode:
#include <stdlib.h>
unsigned long int foo ()
{
unsigned long int longword, magic_bits;
switch (sizeof (longword))
{
case 4: magic_bits = 0x7efefeffL; break;
case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
default: abort ();
}
return magic_bits;
}
This seems like a reasonable error in 32 bit mode, I wonder if the switch
statement should be ifdef's instead so that the LP64 code is not seen in
32 bit mode?
Steve Ellcey
sellcey@imgtec.com