------- Comment #2 from jb at gcc dot gnu dot org 2008-04-14 18:09 ------- Well, your test case is invalid anyway (i0 is referenced before being defined).
Here's a standard conforming portable version that compiles with "-Wall -pedantic -std=f2003": program short_test_inf implicit none integer, parameter :: dp = selected_real_kind (15) complex(dp) nan_inf, normal_number, cmplx_test, i0 real(dp) tth, pi, zero data tth /6.66666666666666667e-01_dp/ data pi /3.1415926535897932385_dp/ data zero /0.0_dp/ normal_number = cmplx(tth, zero, dp) nan_inf = cmplx(pi/zero, zero/zero, dp) i0 = cmplx(0, 0, dp) cmplx_test = nan_inf * normal_number C print *,'nan_inf ',nan_inf print *,'cmplx_test (inf+iNan)*(2/3+i0) ',cmplx_test cmplx_test = nan_inf * tth C print *,'tth ',tth print *,'cmplx_test (inf+iNan)*(2/3)',cmplx_test end program Results with this program comparing 4.1 and 4.4 (trunk): $ ./gf41-opt cmplx_test (inf+iNan)*(2/3+i0) ( NaN, NaN) cmplx_test (inf+iNan)*(2/3) ( +Infinity, NaN) $ ./gf41-nonopt cmplx_test (inf+iNan)*(2/3+i0) ( NaN, NaN) cmplx_test (inf+iNan)*(2/3) ( NaN, NaN) $ ./gf44-opt cmplx_test (inf+iNan)*(2/3+i0) ( +Infinity, NaN) cmplx_test (inf+iNan)*(2/3) ( +Infinity, NaN) $ ./gf44-nonopt cmplx_test (inf+iNan)*(2/3+i0) ( NaN, NaN) cmplx_test (inf+iNan)*(2/3) ( NaN, NaN) Basically, I'd like to close this as wontfix. IIRC once you get an FP exception, all bets are off and the result of further computation can be anything. Of course it would be nice if results were the same regardless of optimization level. For a related issue where being excessively anal about complex arithmetic resulted in a factor of 5 slowdown, see PR 29549 -- jb at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jb at gcc dot gnu dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2008-04-14 18:09:38 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35877