summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0199-2011-04-29-Paolo-Carlini-paolo.carlini-oracle.com.patch
blob: f5ce975b8d5e695183ff3208f60460b19416d8ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Upstream-Status: Inappropriate [Backport]
From 838560450136f202dc9170f2ad3eec80b41e0381 Mon Sep 17 00:00:00 2001
From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 29 Apr 2011 23:19:59 +0000
Subject: [PATCH 199/200] 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.


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

index d36eddc..aa6e81d 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -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
index 0000000..0201cc7
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
@@ -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;
+}
-- 
1.7.0.4

OpenPOWER on IntegriCloud