Another GLIBC build error with GCC6
Steve Ellcey
sellcey@imgtec.com
Tue Jul 21 16:31:00 GMT 2015
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
More information about the Libc-alpha
mailing list