https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68371
Bug ID: 68371
Summary: complex number will be initialized a NAN
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: wuyi at inspur dot com
Target Milestone: ---
while the imaginary part has a NAN or INF,it will affect the real part value;so
the complex number is not correct.
1 #include <stdio.h>
2 #include <math.h>
3 #include <float.h>
4 #include <complex.h>
5
6
7 int main(){
8 // double _Imaginary i = __imag__ I;
9 // printf("I=%g\n",i);
10
11 double complex a,b,c,d;
12
13 a = NAN + 5.0*I;
14 b = 5.0 + NAN*I;
15 c = INFINITY + 5.0*I;
16 d = 5.0 + INFINITY*I;
17 printf("real = %g imag = %g\n",__real__ a,__imag__ a);
18 printf("real = %g imag = %g\n",__real__ b,__imag__ b);
19 printf("real = %g imag = %g\n",__real__ c,__imag__ c);
20 printf("real = %g imag = %g\n",__real__ d,__imag__ d);
21
22 return 0;
23 }
c99 -lm test.c
./a.out
real = nan imag = 5
real = nan imag = nan
real = inf imag = 5
real = nan imag = inf