I have noticed a wierd behavior when using ieee_get_flag.
As an example consider the following.
Compiling the following as a whole (from a single .f90 file, without any compilation options), gives a False for the ieee_invalid flag for 0/0 [ attached file test2.f90 ]:
module my_subs implicit none contains subroutine NaNsub(r1) real,intent(out) :: r1 r1 = 0./0. end subroutine NaNsub end module my_subs program test2 use ieee_exceptions use my_subs implicit none logical :: NaN_found real :: r1 call NaNsub(r1) call ieee_get_flag(ieee_invalid,NaN_found) print *, NaN_found end program test2
However, if I put the module in a seperate file [test3.f90 + NaNsub.f90] compile it and link it to the main code the answer flag becomes true (no compilation options). So I think that something strange happens. Could you please check if you can reproduce this ? Could this behavior be related to the default optimizations used? I'm using v13.1.2 running in Ubuntu 13.01.