I have a program that assigns an array beyond it's bounds, and I was expecting a run-time error to be thrown. Yet no error is raised at all and the program proceeds to write into undeclared memory. Is there some compiler option to guard against this? With the memory dump shown it is clear this overreach of bounds is real. Is there a way to declare variables or argument specs to catch this? Obviously this is a clear case, but when tasked to maintain thousands of lines of F77 derived code it is not always clear (to me) if this might be happening.
PROGRAM TEST_CODE
IMPLICIT NONE
INTEGER*4 :: R(5) ! Array of 5
CALL R_TEST(R, 10)
END PROGRAM
SUBROUTINE R_TEST(R, J)
IMPLICIT NONE
INTEGER*4, INTENT(INOUT) :: R(1) ! Dummy is array of 1
INTEGER*4, INTENT(IN) :: J
INTEGER*4 :: K
DO K=J-5,J+5 ! K=5..15
R(K) = K ! No Runtime Error
END DO
END SUBROUTINE
Compiler is Intel Fortran 2011 XE, and yes I am using the byte spec INTEGER*4
because I know what I get with it.
Here are the compiler options for runtime checking.