In the following code you should get a run-time out of bounds error when compiled with /BOUNDS_CHECK (and with /CHECK, /CHECKMATE) but you don't.
The subroutine attempts to print out the sum of the first n values in array a, but contains a bug and prints out the sum of 10 elements. With bounds checking on there should be an error on the call to sum and on the access to the array section (copied to b).
You do get an error if you try to access, say, a(10), but not when you access the section.
Hope this helps.
subroutine add(a, n)
real a(n), b(10)
! Should get a run time error here (but you don't)
print *, 'Sum is ', sum(a(1:10))
b = a(1:10)
print *, 'Sum is ', sum(b(1:10))
end
program main
real b(10)
b = (/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0/)
! Print out sum of first 5 values (should be 15.0)
call add(b, 5)
end