[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/19577] Gold failed to build with GCC 5.3
From: |
ccoutant at gmail dot com |
Subject: |
[Bug gold/19577] Gold failed to build with GCC 5.3 |
Date: |
Sun, 07 Feb 2016 01:56:10 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=19577
--- Comment #7 from Cary Coutant <ccoutant at gmail dot com> ---
> /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 <address@hidden>
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 gold/19577] New: Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, ccoutant at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, ccoutant at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, cvs-commit at gcc dot gnu.org, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3,
ccoutant at gmail dot com <=
- [Bug gold/19577] Gold failed to build with GCC 5.3, ccoutant at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, cvs-commit at gcc dot gnu.org, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, ccoutant at gmail dot com, 2016/02/06
- [Bug gold/19577] Gold failed to build with GCC 5.3, hjl.tools at gmail dot com, 2016/02/06