[Bug fortran/89920] do loop fails to complete
mark.eggleston at codethink dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 2 08:51:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89920
--- Comment #2 from MarkEggleston <mark.eggleston at codethink dot com> ---
Affects 7, 8 and trunk branches.
A do loop from 1 to the maximum value of an integer does not exit. The example
below has a check that forces the loop to exit.
program test
implicit none
integer(4) :: i
integer(4), parameter :: maximum = huge(i)
integer(4) :: count
logical :: wrap
count = 0
do i = 1,maximum
if (i.gt.0) then
count = count + 1
else
wrap = .true.
exit
endif
enddo
write(*,*) "count ", count
write(*,*) "wrap", wrap
end
When compiled with 6.3 the result is:
count 2147483647
wrap F
When compiled with compiler built using 7, 8 and trunk code on x86_64 the
result is:
count 2147483647
wrap T
Also occurs with integer(1) and integer(2) expect the same is true of
integer(8) and integer(16).
More information about the Gcc-bugs
mailing list