public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25975]  New: Problems with -ffast-math and isnan
@ 2006-01-26 14:41 terra at gnome dot org
  2006-01-26 14:43 ` [Bug c/25975] " terra at gnome dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: terra at gnome dot org @ 2006-01-26 14:41 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-02-17 12:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-25975-4@http.gcc.gnu.org/bugzilla/>
2011-10-17  7:13 ` [Bug c/25975] Problems with -ffast-math and isnan rguenth at gcc dot gnu.org
2011-10-17 15:45 ` paolo.carlini at oracle dot com
2011-10-17 16:49 ` paolo.carlini at oracle dot com
2011-10-17 18:54 ` paolo.carlini at oracle dot com
2011-10-17 19:26 ` pinskia at gcc dot gnu.org
2011-10-17 21:06 ` redi at gcc dot gnu.org
2014-02-17 12:46 ` rguenth at gcc dot gnu.org
2006-01-26 14:41 [Bug c/25975] New: " terra at gnome dot org
2006-01-26 14:43 ` [Bug c/25975] " terra at gnome dot org
2006-01-26 14:44 ` pinskia at gcc dot gnu dot org
2006-01-26 14:47 ` pinskia at gcc dot gnu dot org
2006-01-26 17:22 ` terra at gnome dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).