Annex G of the ISO C99 standard says that a complex value with one part being infinity is considered an infinity, even if the other part is a NaN. It's not clearly stated, but presumably if neither part of the number is an infinity, but one part is a NaN, then the number is a NaN. And presumably if a complex NaN is involved in a math operation, the result should be a complex NaN.
So, I would expect that dividing a complex NaN by a complex 0 would give me a complex NaN. However, when I run this program: #include <stdio.h> #include <math.h> #include <complex.h> __complex float div (__complex float f1, __complex float f2) { return f1 / f2; } int main () { __complex float f; f = div (NAN + NAN * I, 0); printf ("%g+%g*i\n", creal (f), cimag (f)); f = div (1.0 + NAN * I, 0); printf ("%g+%g*i\n", creal (f), cimag (f)); f = div (NAN + 1.0 * I, 0); printf ("%g+%g*i\n", creal (f), cimag (f)); } with current mainline, it prints nan+nan*i nan+nan*i nan+inf*i That last answer seems incorrect according to the rules of Annex G. It is an infinity when it should be a NaN. -- Summary: Complex division with NaN produces unexpected result Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44741