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