This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 1 Dec 2017 14:11:43 +0000
- Subject: Re: [PATCH] Fix overflow in __gnu_cxx::__numeric_traits::__min
- Authentication-results: sourceware.org; auth=none
- References: <20171201140221.GA25409@redhat.com>
On 01/12/17 14:02 +0000, 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: overflow in implicit constant conversion [-Woverflow]
static const _Value __min = __glibcxx_min(_Value);
^~~~~~~~~~~~~