]> code.ossystems Code Review - openembedded-core.git/blob
4cdbd72b449224b4b9712c2521c7d3f82cc55467
[openembedded-core.git] /
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>
5
6         PR libstdc++/48760
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.
12
13
14 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173195 138bc75d-0d04-0410-961f-82ee72b054a4
15
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) { }
21  
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) { }
28 +#else
29 +      {
30 +       __real__ _M_value = __r;
31 +       __imag__ _M_value = __i;
32 +      }
33 +#endif
34  
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) { }
39  
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) { }
46 +#else
47 +      {
48 +       __real__ _M_value = __r;
49 +       __imag__ _M_value = __i;
50 +      }
51 +#endif
52  
53        _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
54        : _M_value(__z.__rep()) { }
55 @@ -1328,7 +1348,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
56  
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) { }
64 +#else
65 +      {
66 +       __real__ _M_value = __r;
67 +       __imag__ _M_value = __i;
68 +      }
69 +#endif
70  
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
74 new file mode 100644
75 index 0000000..0201cc7
76 --- /dev/null
77 +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc
78 @@ -0,0 +1,56 @@
79 +// Copyright (C) 2011 Free Software Foundation, Inc.
80 +//
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.
86 +
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.
91 +
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/>.
95 +
96 +#include <complex>
97 +#include <limits>
98 +#include <testsuite_hooks.h>
99 +
100 +template<typename T>
101 +  void do_test01()
102 +  {
103 +    bool test __attribute__((unused)) = true;
104 +
105 +    if (std::numeric_limits<T>::has_quiet_NaN)
106 +      {
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()) );
110 +
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) );
114 +
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()) );
119 +      }
120 +  }
121 +
122 +// libstdc++/48760
123 +void test01()
124 +{
125 +  do_test01<float>();
126 +  do_test01<double>();
127 +  do_test01<long double>();
128 +}
129 +
130 +int main()
131 +{
132 +  test01();
133 +  return 0;
134 +}
135 -- 
136 1.7.0.4
137