------- Comment #5 from anlauf at gmx dot de 2006-03-17 08:06 ------- (In reply to comment #4) > I will, however, suggest that you reconsider using --fast-math with gfortran. > One of my codes works correctly without --fast-math, but it > will generate NaN's with it. I have not tracked down the problem,
A fairly well-known case is complex division, where -ffast-math assumes a reduced range of the variables so that no overflow can occur. See the gcc option -fno-cx-limited-range for more details. Here's an example where -fno-cx-limited-range does not counter the effect of -ffast-math and produces an NaN: % cat gfc_complex_div.f90 program gfc_complex_div implicit none complex, parameter :: a = 1.e-30 * (1.0, 1.0) print *, cx_div (a, a) contains function cx_div (a, b) complex :: cx_div, a, b cx_div = a / b end function cx_div end program gfc_complex_div % gfc gfc_complex_div.f90 -O && ./a.out ( 1.000000 , 0.000000 ) % gfc gfc_complex_div.f90 -O -ffast-math && ./a.out ( NaN, NaN) % gfc gfc_complex_div.f90 -O -ffast-math -fno-cx-limited-range && ./a.out ( NaN, NaN) I think this used to work (with g77?), but it appears not to work any longer. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26717