This is a follow-up from PR 32315.

The following accesses valid data, but the array bounds are wrong:

program chkdata
    character(len=20), dimension(4,4) :: string
    data ( string(i,1),i=1,5) / 'A', 'B', 'C', 'D', 'E' /
end program chkdata

Since PR 32315 all invalid memory accesses are detected, but here the problem
is that  string(5,1) is invalid (upper bound is 4) while the memory accessed it
part of string (i.e. "string(1,2)").

Expected:
- gfortran rejects this with -std=f95 or at least warns
- The error message should include the bound [e.g. "(5 > 4)"]
  and the dimension ("in dimension 1").

NAG has:
Error: a.f90, line 3: First subscript (5) is greater than upper bound (4) for
array STRING

gfortran has:
Error: Data element above array upper bound at (1)


-- 
           Summary: DATA with implied-do: Improve bounds checking
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35095

Reply via email to