[Bug libfortran/99740] floating point exception in rand() in gfortran
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 23 22:02:56 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99740
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
CC| |kargl at gcc dot gnu.org
Priority|P3 |P4
Resolution|--- |INVALID
--- Comment #2 from kargl at gcc dot gnu.org ---
It is not rand(). Modifying your code gives
program rantest
implicit none
integer*4 i
real*4 x
do i = 1, 7372933
write(11,*) -log(rand(0))
end do
x = rand(0)
write(*,*) x
end
% gfcx -o z -O -ffpe-trap=zero,invalid -g a.f && ./z
0.00000000
log() is from your math library, which likely documents that log(0) returns
divide-by-zero exception. Nothing here to fix.
More information about the Gcc-bugs
mailing list