Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min

2017-12-01 Thread Jonathan Wakely
On 01/12/17 14:34 +, Jonathan Wakely wrote: On 01/12/17 15:22 +0100, Paolo Carlini wrote: Hi, On 01/12/2017 15:11, Jonathan Wakely wrote: On 01/12/17 14:02 +, Jonathan Wakely wrote: Is there a reason we left-shift into the sign bit, causing undefined behaviour? The approach used in st

Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min

2017-12-01 Thread Jonathan Wakely
On 01/12/17 15:22 +0100, Paolo Carlini wrote: Hi, On 01/12/2017 15:11, Jonathan Wakely wrote: On 01/12/17 14:02 +, Jonathan Wakely wrote: Is there a reason we left-shift into the sign bit, causing undefined behaviour? The approach used in std::numeric_limits seems better. The current cod

Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min

2017-12-01 Thread Paolo Carlini
Hi, On 01/12/2017 15:11, Jonathan Wakely wrote: On 01/12/17 14:02 +, Jonathan Wakely wrote: Is there a reason we left-shift into the sign bit, causing undefined behaviour? The approach used in std::numeric_limits seems better. The current code warns with -Wpedantic -Wsystem-headers: /usr

Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min

2017-12-01 Thread Jonathan Wakely
On 01/12/17 14:02 +, Jonathan Wakely wrote: Is there a reason we left-shift into the sign bit, causing undefined behaviour? The approach used in std::numeric_limits seems better. The current code warns with -Wpedantic -Wsystem-headers: /usr/include/c++/7/ext/numeric_traits.h:58:35: warning

[PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min

2017-12-01 Thread Jonathan Wakely
Is there a reason we left-shift into the sign bit, causing undefined behaviour? The approach used in std::numeric_limits seems better. commit e18203057f8e46a3b35239977d8d703df47cdc28 Author: Jonathan Wakely Date: Thu Nov 30 18:15:49 2017 + Fix overflow diff --git a/libstdc++-v3/incl