I would say it is indeed very hard to capture all false positves. Regards,
Arjen Op wo 12 jul 2023 om 17:05 schreef Vivek Rao via Fortran < fortran@gcc.gnu.org>: > For the code > > program main > implicit none > integer, parameter :: n = 10 > real :: x(n), dx(n) > integer :: i > call random_number(x) > do i=1,n > if (i > 1) then > dx(i) = x(i) - x(i-1) > else > dx(i) = 0.0 > end if > end do > print*,dx > end program main > > gfortran -Wextra says for GNU Fortran (GCC) 13.0.0 20221218 > > xspur.f90:9:23: > > > 7 | do i=1,n > | 2 > 8 | if (i > 1) then > 9 | dx(i) = x(i) - x(i-1) > | 1 > Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at > (2) [-Wdo-subscript] > > but the code is fine because of the if guard. Ideally such spurious > messages would be suppressed, but I don't know if this is too hard. > > Vivek Rao >