[Bug fortran/85737] New: gfortran 8.1.0 false positive with -Wdo-subscript

spapanik21 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 10 17:35:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85737

            Bug ID: 85737
           Summary: gfortran 8.1.0  false positive with -Wdo-subscript
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spapanik21 at gmail dot com
  Target Milestone: ---

After the update to gcc-fortran 8.1.0 the following program:

program false_positive
    integer, dimension(5, 5) :: matrix = reshape( &
        (/ &
            32, 63, 93, 53, 69, &
            32, 40, 62, 76, 36, &
            85, 74, 14, 36, 16, &
            16, 23, 57, 15, 54, &
            11, 89, 19, 67, 48  &
        /), &
        shape(matrix), &
        order=(/ 2, 1 /) &
    )
    integer :: i, j, m, n

    m = size(matrix, 1)
    n = size(matrix, 2)
    do i = 1, m
        do j = 1, n
            if (j > 4) then
                print *, matrix(i, j - 3)
            end if
        end do
    end do
end program false_positive

produces the following warning:
stephanos@darwin $ gfortran -Wdo-subscript -c fp.f90
fp.f90:20:35:

fp.f90:18:19:

         do j = 1, n
                   2                
fp.f90:20:35:

                 print *, matrix(i, j - 3)
                                   1
Warning: Array reference at (1) out of bounds (-2 < 1) in loop beginning at (2)
[-Wdo-subscript]

The warning was not present in gcc-fortran 7.3.1


More information about the Gcc-bugs mailing list