1 Upstream-Status: Inappropriate [Backport]
2 From 838560450136f202dc9170f2ad3eec80b41e0381 Mon Sep 17 00:00:00 2001
3 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Fri, 29 Apr 2011 23:19:59 +0000
5 Subject: [PATCH 199/200] 2011-04-29 Paolo Carlini <paolo.carlini@oracle.com>
8 * include/std/complex (complex<float>::complex(float, float),
9 complex<double>::complex(double, double),
10 complex<long double>::complex(long double, long double)): Initialize
11 in the body in C++03 mode (no fix in C++0x mode).
12 * testsuite/26_numerics/complex/cons/48760.cc: New.
15 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173195 138bc75d-0d04-0410-961f-82ee72b054a4
17 index d36eddc..aa6e81d 100644
18 --- a/libstdc++-v3/include/std/complex
19 +++ b/libstdc++-v3/include/std/complex
20 @@ -1046,7 +1046,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
21 _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
23 _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f)
24 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
25 + // The list-initialization extension to __complex__ types is
26 + // not available in GCC 4.6. Thus libstdc++/48760 cannot be
27 + // fixed in C++0x mode, unfortunately.
28 : _M_value(__r + __i * 1.0fi) { }
31 + __real__ _M_value = __r;
32 + __imag__ _M_value = __i;
36 explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&);
37 explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);
38 @@ -1186,7 +1196,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
41 _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0)
42 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
43 + // The list-initialization extension to __complex__ types is
44 + // not available in GCC 4.6. Thus libstdc++/48760 cannot be
45 + // fixed in C++0x mode, unfortunately.
46 : _M_value(__r + __i * 1.0i) { }
49 + __real__ _M_value = __r;
50 + __imag__ _M_value = __i;
54 _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
55 : _M_value(__z.__rep()) { }
56 @@ -1328,7 +1348,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
58 _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L,
59 long double __i = 0.0L)
60 +#ifdef __GXX_EXPERIMENTAL_CXX0X__
61 + // The list-initialization extension to __complex__ types is
62 + // not available in GCC 4.6. Thus libstdc++/48760 cannot be
63 + // fixed in C++0x mode, unfortunately.
64 : _M_value(__r + __i * 1.0Li) { }
67 + __real__ _M_value = __r;
68 + __imag__ _M_value = __i;
72 _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
73 : _M_value(__z.__rep()) { }
74 diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
76 index 0000000..0201cc7
78 +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
80 +// Copyright (C) 2011 Free Software Foundation, Inc.
82 +// This file is part of the GNU ISO C++ Library. This library is free
83 +// software; you can redistribute it and/or modify it under the
84 +// terms of the GNU General Public License as published by the
85 +// Free Software Foundation; either version 3, or (at your option)
86 +// any later version.
88 +// This library is distributed in the hope that it will be useful,
89 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
90 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91 +// GNU General Public License for more details.
93 +// You should have received a copy of the GNU General Public License along
94 +// with this library; see the file COPYING3. If not see
95 +// <http://www.gnu.org/licenses/>.
99 +#include <testsuite_hooks.h>
101 +template<typename T>
104 + bool test __attribute__((unused)) = true;
106 + if (std::numeric_limits<T>::has_quiet_NaN)
108 + std::complex<T> c1(T(0), std::numeric_limits<T>::quiet_NaN());
109 + VERIFY( c1.real() == T(0) );
110 + VERIFY( std::isnan(c1.imag()) );
112 + std::complex<T> c2(std::numeric_limits<T>::quiet_NaN(), T(0));
113 + VERIFY( std::isnan(c2.real()) );
114 + VERIFY( c2.imag() == T(0) );
116 + std::complex<T> c3(std::numeric_limits<T>::quiet_NaN(),
117 + std::numeric_limits<T>::quiet_NaN());
118 + VERIFY( std::isnan(c3.real()) );
119 + VERIFY( std::isnan(c3.imag()) );
126 + do_test01<float>();
127 + do_test01<double>();
128 + do_test01<long double>();