This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/24581] New: Complex arithmetic on special cases is incorrect.
- From: "kargl at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Oct 2005 19:27:47 -0000
- Subject: [Bug c/24581] New: Complex arithmetic on special cases is incorrect.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
/*
* The C99 standard intends x+I*y to be used for this, but x+I*y is
* currently unusable because gcc introduces many overflow,
* underflow, sign and efficiency bugs by rewriting I*y as
* (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
* In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
* to -0.0+I*0.0.
*/
#include <complex.h>
#include <math.h>
#include <stdio.h>
int main(void) {
double complex z;
double x, y;
x = 0.;
y = 1. / x;
x = copysign(x, -1.);
/* z = 0 + i (-0) */
z = I * x;
printf("%e %e\n", creal(z), cimag(z));
/* z = 0 + i Inf */
z = I * y;
printf("%e %e\n", creal(z), cimag(z));
}
kargl[223] gcc -o z a.c -lm
kargl[224] ./z
-0.000000e+00 0.000000e+00
nan inf
This bug is in 3.4.4 up to an including mainline.
--
Summary: Complex arithmetic on special cases is incorrect.
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kargl at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24581