https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89821
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Tue, Mar 26, 2019 at 06:34:09PM +0000, kargl at gcc dot gnu.org wrote: > > This reduced testcase fails with 8-branch and trunk when compiled > with -ffpe-trap=invalid. > > program demo_nan > use,intrinsic :: iso_fortran_env, only: real32 > implicit none > character(len=3),save :: STRING='NaN' > real(kind=real32) :: r32 > character(len=256) :: message > integer :: ios > read(STRING,*)r32 > ! an option to terminate a program when a NaN is encountered > ! (if X is NaN the comparison with 0. is always false.) > if ( (r32<=0.0_real32) .or. (r32>=0.0_real32) )then > write(*,*)'did not produce a nan_real32' > else > write(*,*)'found a nan_real32. Handle it.' > endif > ! list directed format > write(*,*,iomsg=message,iostat=ios)r32 > if(ios.ne.0)write(*,*)trim(message) > ! hexadecimal format to show different kinds > write(*,'(z0)',iomsg=message,iostat=ios)r32 > end program demo_nan > > The above compiles with both 6-branch and an old 7-branch > (need to update 7 to test). With an up-to-date 7-branch, if one builds an executable with -ffpe-trap=invalid, the exexcutable with die with a SIGFPE.