https://sourceware.org/bugzilla/show_bug.cgi?id=19577
--- Comment #8 from Cary Coutant <ccoutant at gmail dot com> --- Sorry, that patch was stale. Here's the correct version. -cary On Sat, Feb 6, 2016 at 5:55 PM, Cary Coutant <ccout...@gmail.com> wrote: >> /export/gnu/import/git/sources/binutils-gdb/gold/reloc.h:1009:37: error: >> integer overflow in expression [-Werror=overflow] >> int32_t max = (1 << (bits - 1)) - 1; >> ^ > >> /export/gnu/import/git/sources/binutils-gdb/gold/reloc.h:1023:46: error: left >> shift count >= width of type [-Werror=shift-count-overflow] >> uint32_t max = static_cast<uint32_t>((1U << bits) - 1); > > Hmmm, in both of these cases, I'd have expected the compiler to do > enough constant propagation to see that the code it's complaining > about is dead when bits == 32. > > Here's a patch that I think makes the code both clearer and more > compiler-proof. > > I'm having trouble doing a full build with the trunk compiler, but I > did do some testing on the side to try to make sure this code compiles > clean and correctly. (I'm running stock Ubuntu on a VM, with GCC 4.8.2 > installed. And no multilib either.) > > -cary > > > 2016-02-06 Cary Coutant <ccout...@gmail.com> > > gold/ > * reloc.h (Limits): New class. > (Bits::has_overflow32): Use min/max values from Limits. > (Bits::has_unsigned_overflow32): Likewise. > (Bits::has_signed_unsigned_overflow32): Likewise. > (Bits::has_overflow): Likewise. > (Bits::has_unsigned_overflow): Likewise. > (Bits::has_signed_unsigned_overflow64): Likewise. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils