[Bug middle-end/23497] [4.1 regression] Bogus 'is used uninitialized...' warning about std::complex<T>
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 15 21:51:00 GMT 2005
------- Comment #16 from pinskia at gcc dot gnu dot org 2005-11-15 21:51 -------
Here is the current patch so for libstdc++ (I did not test it yet):
Index: include/std/std_complex.h
===================================================================
--- include/std/std_complex.h (revision 106892)
+++ include/std/std_complex.h (working copy)
@@ -1061,29 +1061,27 @@ namespace std
inline
complex<float>::complex(float r, float i)
{
- __real__ _M_value = r;
- __imag__ _M_value = i;
+ _M_value = r + i * 1.0fi;
}
inline complex<float>&
complex<float>::operator=(float __f)
{
- __real__ _M_value = __f;
- __imag__ _M_value = 0.0f;
+ _M_value = __f;
return *this;
}
inline complex<float>&
complex<float>::operator+=(float __f)
{
- __real__ _M_value += __f;
+ _M_value += __f;
return *this;
}
inline complex<float>&
complex<float>::operator-=(float __f)
{
- __real__ _M_value -= __f;
+ _M_value -= __f;
return *this;
}
@@ -1105,8 +1103,7 @@ namespace std
inline complex<float>&
complex<float>::operator=(const complex<_Tp>& __z)
{
- __real__ _M_value = __z.real();
- __imag__ _M_value = __z.imag();
+ _M_value = __z.real() + __z.imag() * 1.0fi;
return *this;
}
@@ -1114,8 +1111,7 @@ namespace std
inline complex<float>&
complex<float>::operator+=(const complex<_Tp>& __z)
{
- __real__ _M_value += __z.real();
- __imag__ _M_value += __z.imag();
+ _M_value += __z.real() + __z.imag() * 1.0fi;
return *this;
}
@@ -1123,8 +1119,7 @@ namespace std
inline complex<float>&
complex<float>::operator-=(const complex<_Tp>& __z)
{
- __real__ _M_value -= __z.real();
- __imag__ _M_value -= __z.imag();
+ _M_value -= __z.real() + __z.imag() * 1.0fi;
return *this;
}
@@ -1132,9 +1127,7 @@ namespace std
inline complex<float>&
complex<float>::operator*=(const complex<_Tp>& __z)
{
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
+ _ComplexT __t = __z.real() + __z.imag() * 1.0fi;
_M_value *= __t;
return *this;
}
@@ -1143,9 +1136,7 @@ namespace std
inline complex<float>&
complex<float>::operator/=(const complex<_Tp>& __z)
{
- _ComplexT __t;
- __real__ __t = __z.real();
- __imag__ __t = __z.imag();
+ _ComplexT __t = __z.real() + __z.imag() * 1.0fi;
_M_value /= __t;
return *this;
}
This also makes more and more optimization opertinutes for complex in
libstdc++. This also makes this code a little more readible.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23497
More information about the Gcc-bugs
mailing list