[Bug middle-end/31354] New: NaN should only fail comparisons for equality

tkoenig at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Mar 25 22:22:00 GMT 2007


I'm guessing at middle-end here, maybe it is target...

I don't think it is correct for NaNs to fail any comparison.
They should only fail comparisons which include equality.

$ cat compare.c
#include <stdio.h>

int main()
{
   float nan, x;
   nan = 0.0;
   nan = nan / nan;
   x = 3.2;
   printf("%f\n", nan);
   printf("%d %d %d %d\n", x > nan, x < nan, x >= nan, x <= nan);
   return 0;
}
$ gcc compare.c && ./a.out
nan
0 0 0 0
$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/ig25/gcc/trunk/configure --prefix=/home/ig25
--enable-maintainer-mode --enable-languages=c,fortran
Thread model: posix
gcc version 4.3.0 20070317 (experimental)


-- 
           Summary: NaN should only fail comparisons for equality
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list