Loop variable reaching integer `huge` causes infinite loop

Note that -huge(i) will not return the smallest possible integer:

print*, -huge(1)    ! -> -2147483647
print*, -huge(1)-1  ! -> -2147483648
print*, -huge(1)-2  ! -> Error: Arithmetic overflow
1 Like