OSDN Git Service

2011-04-29 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Apr 2011 23:19:59 +0000 (23:19 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Apr 2011 23:19:59 +0000 (23:19 +0000)
PR libstdc++/48760
* include/std/complex (complex<float>::complex(float, float),
complex<double>::complex(double, double),
complex<long double>::complex(long double, long double)): Initialize
in the body in C++03 mode (no fix in C++0x mode).
* testsuite/26_numerics/complex/cons/48760.cc: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173195 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/complex
libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc [new file with mode: 0644]

index 437bded..012cf1d 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-29  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/48760
+       * include/std/complex (complex<float>::complex(float, float),
+       complex<double>::complex(double, double),
+       complex<long double>::complex(long double, long double)): Initialize
+       in the body in C++03 mode (no fix in C++0x mode).
+       * testsuite/26_numerics/complex/cons/48760.cc: New.
+
 2011-04-23  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
        PR libstdc++/48521
@@ -10,7 +19,7 @@
        (ref(const A&&), cref(const A&&): Define as deleted.
        * include/std/future (async): Simplify SFINAE and use result_of to
        support pointer to member.
-       * testsuite/20_util/reference_wrapper/invoke.cc: Test pointer to 
+       * testsuite/20_util/reference_wrapper/invoke.cc: Test pointer to
        member.
        * testsuite/20_util/reference_wrapper/24803.cc: Likewise.
        * testsuite/20_util/reference_wrapper/typedefs.cc: Test for types
index d36eddc..aa6e81d 100644 (file)
@@ -1046,7 +1046,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
 
       _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // The list-initialization extension to __complex__ types is
+      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
+      // fixed in C++0x mode, unfortunately.
       : _M_value(__r + __i * 1.0fi) { }
+#else
+      {
+       __real__ _M_value = __r;
+       __imag__ _M_value = __i;
+      }
+#endif
 
       explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&);
       explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);        
@@ -1186,7 +1196,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
 
       _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // The list-initialization extension to __complex__ types is
+      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
+      // fixed in C++0x mode, unfortunately.
       : _M_value(__r + __i * 1.0i) { }
+#else
+      {
+       __real__ _M_value = __r;
+       __imag__ _M_value = __i;
+      }
+#endif
 
       _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
       : _M_value(__z.__rep()) { }
@@ -1328,7 +1348,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, 
                                 long double __i = 0.0L)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      // The list-initialization extension to __complex__ types is
+      // not available in GCC 4.6.  Thus libstdc++/48760 cannot be
+      // fixed in C++0x mode, unfortunately.
       : _M_value(__r + __i * 1.0Li) { }
+#else
+      {
+       __real__ _M_value = __r;
+       __imag__ _M_value = __i;
+      }
+#endif
 
       _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
       : _M_value(__z.__rep()) { }
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
new file mode 100644 (file)
index 0000000..0201cc7
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// 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 <complex>
+#include <limits>
+#include <testsuite_hooks.h>
+
+template<typename T>
+  void do_test01()
+  {
+    bool test __attribute__((unused)) = true;
+
+    if (std::numeric_limits<T>::has_quiet_NaN)
+      {
+       std::complex<T> c1(T(0), std::numeric_limits<T>::quiet_NaN());
+       VERIFY( c1.real() == T(0) );
+       VERIFY( std::isnan(c1.imag()) );
+
+       std::complex<T> c2(std::numeric_limits<T>::quiet_NaN(), T(0));
+       VERIFY( std::isnan(c2.real()) );
+       VERIFY( c2.imag() == T(0) );
+
+       std::complex<T> c3(std::numeric_limits<T>::quiet_NaN(),
+                          std::numeric_limits<T>::quiet_NaN());
+       VERIFY( std::isnan(c3.real()) );
+       VERIFY( std::isnan(c3.imag()) );
+      }
+  }
+
+// libstdc++/48760
+void test01()
+{
+  do_test01<float>();
+  do_test01<double>();
+  do_test01<long double>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}