From: Paolo Carlini Date: Thu, 12 Jun 2008 10:17:53 +0000 (+0000) Subject: complex (pow(const complex<>&, int)): Do not define in C++0x mode, per DR 844. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3fd29fa912911b3db52046ef0d44144dd0e043ee;p=gcc.git complex (pow(const complex<>&, int)): Do not define in C++0x mode, per DR 844. 2008-06-12 Paolo Carlini * 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. From-SVN: r136694 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 94cbefa52ff..933bff852f3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2008-06-12 Paolo Carlini + + * 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 * include/tr1_impl/hashtable (_Hashtable<>::cbegin(size_type), diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index 309871b5c32..e30e81dcbfe 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -677,6 +677,12 @@ In C++0x mode, add std::proj. + + 844: + complex pow return type is ambiguous + + In C++0x mode, remove the pow(complex<T>, int) signature. + diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 0fa381cbeac..c8845f6728c 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -82,8 +82,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template complex<_Tp> log(const complex<_Tp>&); /// Return complex base 10 logarithm of @a z. template 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 complex<_Tp> pow(const complex<_Tp>&, int); +#endif /// Return @a x to the @a y'th power. template 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 inline complex<_Tp> pow(const complex<_Tp>& __z, int __n) { return std::__pow_helper(__z, __n); } +#endif template complex<_Tp> diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex index b571a5982ed..88c37de75d2 100644 --- a/libstdc++-v3/include/tr1/complex +++ b/libstdc++-v3/include/tr1/complex @@ -76,11 +76,6 @@ namespace tr1 using std::real; - template - inline std::complex<_Tp> - pow(const std::complex<_Tp>& __x, int __n) - { return std::pow(__x, __n); } - template inline std::complex<_Tp> pow(const std::complex<_Tp>& __x, const _Tp& __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 index 00000000000..e9bb192d6e9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-12 Paolo Carlini +// +// 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 +#include +#include + +// DR 844. complex pow return type is ambiguous. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex cmplx_f_type; + typedef std::complex cmplx_d_type; + typedef std::complex 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(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(std::pow(cmplx_d_type(d1, d1), i1)); + check_ret_type(std::pow(cmplx_ld_type(ld1, ld1), i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc index b0183514537..231581f9d5c 100644 --- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc +++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc @@ -1,6 +1,6 @@ // 2006-01-12 Paolo Carlini // -// 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 cmplx_i_type; check_ret_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(std::tr1::pow(cmplx_f_type(f1, f1), i1)); - check_ret_type(std::tr1::pow(cmplx_f_type(f1, f1), i1)); - + check_ret_type(std::tr1::pow(cmplx_f_type(f1, f1), i1)); check_ret_type(std::tr1::pow(cmplx_f_type(f1, f1), u1)); check_ret_type(std::tr1::pow(cmplx_f_type(f1, f1), l1)); check_ret_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)