http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57675

            Bug ID: 57675
           Summary: Complex division of NaN by zero not handled correctly
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian at airs dot com

The rules in C99 Annex G say that if either part of a complex number is
infinity, then the whole number is treated as infinity.  The rules imply but do
not clearly state that an operation involving a NaN should yield a NaN. 
However, this program aborts:

__complex double f (__complex double, __complex double)
  __attribute__ ((noinline));
__complex double
f (__complex double a, __complex double b)
{
  return a / b;
}

int
main ()
{
  __complex double c = f (__builtin_nan("") + 1.0i, 0);
  if (__builtin_isinf (__real__ c) || __builtin_isinf (__imag__ c))
    abort ();
  exit (0);
}

Computing NaN+1.0i / 0+0i yields NaN+Inf*I.  The rules of Annex G say that the
latter is infinity.  But the result of dividing a NaN by 0 should be NaN, just
as the result of any operation involving NaN should be NaN.

Reply via email to