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]

Another GLIBC build error with GCC6


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




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