nan -ffast-math

Jim Wilson wilson@specifixinc.com
Thu Feb 5 19:44:00 GMT 2004


Antonio Bleile wrote:
> When compiled without any flag, like "gcc bug.c"
> the output of the program will be "NAN != 0.0".
> When compiled with "gcc bug.c -ffast-math"
> the output is "NAN == 0.0", which is, in my opinion,
> wrong

This is what -ffast-math is desgined to do.  See the documentation for 
this option.

-ffast-math results in faster FP code by making potentially unsafe 
simplifying assumptions, such as pretending that NaNs and Infinities 
don't exist.  If your code requires NaNs and Infinities to work, then 
you can't use the -ffast-math option.

Recent gcc versions split -ffast-math into several suboptions, one of 
which is -ffinite-math-only, so you can choose whether you want NaNs and 
Infinities to work, while still getting the other benefits of -ffast-math.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc-bugs mailing list