This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/24581] Complex arithmetic on special cases is incorrect.


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 ;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]