[Bug fortran/94978] [13/14/15/16 Regression] Bogus warning "Array reference at (1) out of bounds in loop beginning at (2)"

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 10 15:51:31 GMT 2026


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

--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:790671b708400d1fc6bb1abbf1601f3616e8220d

commit r16-8564-g790671b708400d1fc6bb1abbf1601f3616e8220d
Author: Christopher Albert <albert@tugraz.at>
Date:   Sat Mar 28 17:26:05 2026 +0100

    fortran: Avoid bogus do-subscript warnings in skipped inner loops [PR94978]

    Do not warn from an outer-loop bound substitution when a nested inner loop
may
    be zero-trip after that substitution, because the guarded array reference
may
    then be unreachable.

    gcc/fortran/ChangeLog:

            PR fortran/94978
            * frontend-passes.cc (evaluate_loop_bound): New helper.
            (inner_loop_may_be_skipped): New helper.
            (do_subscript): Skip outer-loop bound warnings when nested inner
loops
            may be zero-trip for the substituted bound.

    gcc/testsuite/ChangeLog:

            PR fortran/94978
            * gfortran.dg/pr94978.f90: New test.

    Signed-off-by: Christopher Albert <albert@tugraz.at>


More information about the Gcc-bugs mailing list