The suggestion/feature request grew out of an experience with a 20,000 line program (550 kbytes).
The NAG compiler was finding an undefined variable with this program, but FTN95 and Lahey found no such error. As usual, it took quite a bit of effort to find the explanation.
Here is a short example.
program undef
implicit none
integer :: i, ka, ix(3)
!
call init(3,ix,ka)
do i=1,3
if(ka > 2 .and. ix(i) >= 0)then
print *,'Found a case, i = ',i
endif
end do
end program
subroutine init(n,ia,k)
implicit none
integer k, n, ia(n)
k=2
ia(k) = 3
return
end
The IF statement on the seventh line contains two expressions with an .AND. between them. The values of the variables in the expressions are such that the second part, IX(I) >= 0, need not be evaluated, but the compiler may decide to evaluate the second part. The programmer has to ensure that IX(I) is defined, and may expect the compiler to help with shortcomings when /checkmate or /undef has been specified.
Please consider the following change to the behavior of the checking code that is generated when /checkmate is specified. Ascertain whether all the expressions in the IF() have defined values, and issue the usual error messages if not. In other words, /checkmate or /undef would imply 'No short-circuit evaluation'. For the example code above, the programmer would find out with the compiler's help that IX(1) and IX(3) are undefined.
Thanks for your consideration.