OSDN Git Service

2008-06-12 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jun 2008 10:17:53 +0000 (10:17 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jun 2008 10:17:53 +0000 (10:17 +0000)
* include/std/complex (pow(const complex<>&, int)): Do not define in
C++0x mode, per DR 844.
* include/tr1/complex (pow(const complex<>&, int)): Remove.
* doc/xml/manual/intro.xml: Add an entry for DR 844.
* testsuite/26_numerics/complex/dr844.cc: New.
* testsuite/tr1/8_c_compatibility/complex/overloads_int.cc: Adjust.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136694 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/doc/xml/manual/intro.xml
libstdc++-v3/include/std/complex
libstdc++-v3/include/tr1/complex
libstdc++-v3/testsuite/26_numerics/complex/dr844.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc

index 94cbefa..933bff8 100644 (file)
@@ -1,3 +1,12 @@
+2008-06-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/std/complex (pow(const complex<>&, int)): Do not define in
+       C++0x mode, per DR 844.
+       * include/tr1/complex (pow(const complex<>&, int)): Remove.
+       * doc/xml/manual/intro.xml: Add an entry for DR 844.
+       * testsuite/26_numerics/complex/dr844.cc: New.
+       * testsuite/tr1/8_c_compatibility/complex/overloads_int.cc: Adjust.
+
 2008-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/tr1_impl/hashtable (_Hashtable<>::cbegin(size_type),
index 309871b..e30e81d 100644 (file)
     </term>
     <listitem><para>In C++0x mode, add std::proj.
     </para></listitem></varlistentry>
+
+    <varlistentry><term><ulink url="../ext/lwg-active.html#844">844</ulink>:
+        <emphasis>complex pow return type is ambiguous</emphasis>
+    </term>
+    <listitem><para>In C++0x mode, remove the pow(complex&lt;T&gt;, int) signature.
+    </para></listitem></varlistentry>
   </variablelist>
 
  </sect2>
index 0fa381c..c8845f6 100644 (file)
@@ -82,8 +82,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   template<typename _Tp> complex<_Tp> log(const complex<_Tp>&);
   /// Return complex base 10 logarithm of @a z.
   template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&);
-  /// Return complex cosine of @a z.
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+  // DR 844.
+  /// Return @a x to the @a y'th power.
   template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int);
+#endif
   /// Return @a x to the @a y'th power.
   template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
   /// Return @a x to the @a y'th power.
@@ -945,10 +948,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   // 26.2.8/9  pow(__x, __y): Returns the complex power base of __x
   //                          raised to the __y-th power.  The branch
   //                          cut is on the negative axis.
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // DR 844. complex pow return type is ambiguous.
   template<typename _Tp>
     inline complex<_Tp>
     pow(const complex<_Tp>& __z, int __n)
     { return std::__pow_helper(__z, __n); }
+#endif
 
   template<typename _Tp>
     complex<_Tp>
index b571a59..88c37de 100644 (file)
@@ -78,11 +78,6 @@ namespace tr1
 
   template<typename _Tp>
     inline std::complex<_Tp>
-    pow(const std::complex<_Tp>& __x, int __n)
-    { return std::pow(__x, __n); }
-
-  template<typename _Tp>
-    inline std::complex<_Tp>
     pow(const std::complex<_Tp>& __x, const _Tp& __y)
     { return std::pow(__x, __y); }
 
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc
new file mode 100644 (file)
index 0000000..e9bb192
--- /dev/null
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++0x" }
+// 2008-06-12  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2008 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <complex>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+// DR 844. complex pow return type is ambiguous.
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+  using __gnu_test::check_ret_type;
+
+  typedef std::complex<float>       cmplx_f_type;
+  typedef std::complex<double>      cmplx_d_type;
+  typedef std::complex<long double> cmplx_ld_type;
+
+  const int          i1 = 1;
+  const float        f1 = 1.0f;
+  const double       d1 = 1.0;
+  const long double ld1 = 1.0l;
+
+  check_ret_type<cmplx_d_type>(std::pow(cmplx_f_type(f1, f1), i1));
+  VERIFY( std::pow(cmplx_f_type(f1, f1), i1)
+         == std::pow(cmplx_d_type(f1, f1), double(i1)) );
+  check_ret_type<cmplx_d_type>(std::pow(cmplx_d_type(d1, d1), i1));
+  check_ret_type<cmplx_ld_type>(std::pow(cmplx_ld_type(ld1, ld1), i1));
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index b018351..231581f 100644 (file)
@@ -1,6 +1,6 @@
 // 2006-01-12  Paolo Carlini  <pcarlini@suse.de>
 //
-// Copyright (C) 2006 Free Software Foundation, Inc.
+// Copyright (C) 2006, 2007, 2008 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
@@ -64,18 +64,13 @@ void test01()
   typedef std::complex<int> cmplx_i_type;
   check_ret_type<cmplx_i_type>(std::tr1::polar(i1, i1));
 
-  // NB: According to the letter of 8.1.9/3 the return type should be a
-  // cmplx_d_type, but the existing std::pow(const complex<>&, int) wins.
-  // check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1));
-  check_ret_type<cmplx_f_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1));
-
+  check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1));
   check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), u1));
   check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), l1));
   check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_d_type(d1, d1), i1));
 
-  // See last comment.
-  // VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), i1)
-  //         == std::tr1::pow(cmplx_d_type(d1, d1), double(i1)) );
+  VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), i1)
+         == std::tr1::pow(cmplx_d_type(d1, d1), double(i1)) );
   VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), u1)
          == std::tr1::pow(cmplx_d_type(d1, d1), double(u1)) );
   VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), l1)