Apologies as this may have been discussed before.
Consider the following tiny program:
program test_huge
use iso_fortran_env, only: int8
integer(int8) :: i
do i=-huge(i),huge(i)
print "('i=',i10,' b=',b8.8)", i,i
end do
end
~
With gfortran 12.2 on Mac, this causes an infinite loop that never ends. I guess there is a problem with huge(i)=127
, because if use the same bounds with an implicit loop, I get:
./test_huge.f90:3:62:
3 | integer(int8), parameter :: a(*) = [(i,i=-huge(i),huge(i))]
| 1
Warning: DO loop at (1) is undefined as it overflows [-Wundefined-do-loop]
Shouldnāt a 1-byte signed integer value be in the [-128, 127]
range?
EDIT: godbolt shows no issues with other compilers, so this may just be GNU-specific.