The following program should print "Got a NaN": > gcc-4.0.2 nan.c && ./a.out Got a NaN
...but... > gcc-4.0.2 -ffast-math nan.c && ./a.out Ugh! I don't think that is proper behaviour even for -ffast-math. This came up because someone compiled Gnumeric with -ffast-math. It seems that this option is thought of as "make my program faster" with no mention of its meaning-altering effects by lots and lots of people out there. #include <math.h> #include <stdio.h> int main (int argc, char **argv) { double d; if (sscanf ("NaN", "%lf", &d) != 1) d = 0; if (isnan (d)) printf ("Got a NaN\n"); else printf ("Ugh!\n"); return 0; } -- Summary: Problems with -ffast-math and isnan Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: terra at gnome dot org GCC build triplet: 686-pc-linux-gnu GCC host triplet: 686-pc-linux-gnu GCC target triplet: 686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25975