program toto implicit none real :: a(10) integer :: i a(:) = 1. do i=1,100 if( i <= 10 .and. a(i) > 0. ) write(*,*) i,a(i) enddo end Compiling this program with -fbounds-check will give an out-of-bound error because the bound checking happens before the evaluation of the expression. As short-circuit (i.e. not evaluating the second part of the expression when its result is determined by the first part) is used by gfortran, it would be nice to use it also for bound checking (at least as an option).
-- Summary: short-circuit in -fbounds-check Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mimo2 at free dot fr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31269