https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128793
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:563fa2230a5eed94c5771b38b2e140e6f6885393 commit r17-6371-g563fa2230a5eed94c5771b38b2e140e6f6885393 Author: Jerry DeLisle <[email protected]> Date: Mon Nov 16 17:54:02 2026 -0800 fortran: [PR128793] Evaluate DO CONCURRENT limits and step once The serial loops of DO CONCURRENT read the variables referenced by the concurrent-limits and concurrent-steps again during the iterations, so a body that defined one changed which iterations ran, although F2018 11.1.7.4.2 evaluates them once. This was because gfc_trans_forall_1 recorded the end and step for the loops before gfc_make_safe_expr copied them into temporaries, and never made the start safe. For an outermost FORALL or DO CONCURRENT, evaluate the start once too and have the loops use the evaluated start, end and step. A nested FORALL is left alone, since its limits may use the outer index-names. Assisted-by: Claude Opus 5.5 PR fortran/128793 gcc/fortran/ChangeLog: * trans-stmt.cc (gfc_trans_forall_1): For an outermost construct, evaluate the start once and use the evaluated start, end and step in the loops. gcc/testsuite/ChangeLog: * gfortran.dg/do_concurrent_16.f90: New test.
