limits (numeric_limits): Fix returns per C++11.
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 2 Mar 2012 22:24:45 +0000 (22:24 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 2 Mar 2012 22:24:45 +0000 (22:24 +0000)
2012-03-02  Paolo Carlini  <paolo.carlini@oracle.com>

* include/std/limits (numeric_limits): Fix returns per C++11.
* testsuite/18_support/numeric_limits/primary.cc: New.

From-SVN: r184837

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/limits
libstdc++-v3/testsuite/18_support/numeric_limits/primary.cc [new file with mode: 0644]

index d49c6a4bdf492f90294dadedbc88955a88b36b63..3abfc9435af48b03a2200d08c82d6a9dd013f880 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/std/limits (numeric_limits): Fix returns per C++11.
+       * testsuite/18_support/numeric_limits/primary.cc: New.
+
 2012-03-02  Benjamin Kosnik  <bkoz@redhat.com>
 
        * include/c_global/cstdio: Remove extraneous extern.
index ea37d9d20cd592dc8cfdf9472cce30b2abf4a240..e7a6e8fa934184348e93f03932557b276eaed71f 100644 (file)
@@ -306,47 +306,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       /** The minimum finite value, or for floating types with
          denormalization, the minimum positive normalized value.  */
       static _GLIBCXX_CONSTEXPR _Tp
-      min() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The maximum finite value.  */
       static _GLIBCXX_CONSTEXPR _Tp
-      max() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
       /** A finite value x such that there is no other finite value y
        *  where y < x.  */
       static constexpr _Tp
-      lowest() noexcept { return static_cast<_Tp>(0); }
+      lowest() noexcept { return _Tp(); }
 #endif
 
       /** The @e machine @e epsilon:  the difference between 1 and the least
          value greater than 1 that is representable.  */
       static _GLIBCXX_CONSTEXPR _Tp
-      epsilon() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      epsilon() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The maximum rounding error measurement (see LIA-1).  */
       static _GLIBCXX_CONSTEXPR _Tp
-      round_error() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      round_error() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The representation of positive infinity, if @c has_infinity.  */
       static _GLIBCXX_CONSTEXPR _Tp
-      infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      infinity() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The representation of a quiet <em>Not a Number</em>,
          if @c has_quiet_NaN. */
       static _GLIBCXX_CONSTEXPR _Tp
-      quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The representation of a signaling <em>Not a Number</em>, if
          @c has_signaling_NaN. */
       static _GLIBCXX_CONSTEXPR _Tp
-      signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
 
       /** The minimum positive denormalized value.  For types where
          @c has_denorm is false, this is the minimum positive normalized
          value.  */
       static _GLIBCXX_CONSTEXPR _Tp
-      denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<_Tp>(0); }
+      denorm_min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
     };
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/primary.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/primary.cc
new file mode 100644 (file)
index 0000000..833b27a
--- /dev/null
@@ -0,0 +1,24 @@
+// { dg-do compile }
+
+// Copyright (C) 2012 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <limits>
+
+struct MyBigNum { };
+
+template class std::numeric_limits<MyBigNum>;