]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid -Woverflow warning in __numeric_limits_integer
authorJonathan Wakely <jwakely@redhat.com>
Fri, 3 May 2019 19:13:31 +0000 (20:13 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 3 May 2019 19:13:31 +0000 (20:13 +0100)
This is the same fix as was done for std::numeric_limits in r183905.

PR libstdc++/52119
* include/ext/numeric_traits.h (__glibcxx_min): Avoid integer
overflow warning with -Wpedantic -Wsystem-headers.

From-SVN: r270858

libstdc++-v3/ChangeLog
libstdc++-v3/include/ext/numeric_traits.h

index 6c93604d3187c00ac0506b4c5bbf269d9cf7adeb..b1390142cb18bca42836f4015348c82b537c3453 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-03  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/52119
+       * include/ext/numeric_traits.h (__glibcxx_min): Avoid integer
+       overflow warning with -Wpedantic -Wsystem-headers.
+
 2019-05-02  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/90314
index 67993fdc58ee66267d6add1e12174cb23418aa81..43ba1c8740a8853b631be6dc3e44ccca60e2d711 100644 (file)
@@ -39,13 +39,13 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Compile time constants for builtin types.
-  // Sadly std::numeric_limits member functions cannot be used for this.
+  // In C++98 std::numeric_limits member functions cannot be used for this.
 #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
 #define __glibcxx_digits(_Tp) \
   (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
 
 #define __glibcxx_min(_Tp) \
-  (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
+  (__glibcxx_signed(_Tp) ? -__glibcxx_max(_Tp) - 1 : (_Tp)0)
 
 #define __glibcxx_max(_Tp) \
   (__glibcxx_signed(_Tp) ? \