This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/24581] Complex arithmetic on special cases is incorrect.
- From: "marco_atzeri at yahoo dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 21 Nov 2010 19:49:31 +0000
- Subject: [Bug c/24581] Complex arithmetic on special cases is incorrect.
- Auto-submitted: auto-generated
- References: <bug-24581-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24581
marco atzeri <marco_atzeri at yahoo dot it> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marco_atzeri at yahoo dot
| |it
--- Comment #11 from marco atzeri <marco_atzeri at yahoo dot it> 2010-11-21 19:48:40 UTC ---
the compiler produce incorrect output also when multiplying
pure complex numbers (but not adding them).
Using gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4) on x86_64
The outcome of the following code is
(inf,0)
(-nan,inf)
(inf,-nan)
instead of the expected
(inf,0)
(0,inf)
(inf,0)
---------------------------------------------------
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex<double> z;
complex<double> z2;
complex<double> z3;
double a = 0;
double b = 1. / a;
z = complex<double> (b,a);
z2 = complex<double> (0,1);
z3 = complex<double> (1,0);
std::cout << z << '\n';
z2 = z * z2 ;
std::cout << z2 << '\n';
z3 = z * z3 ;
}