https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125192
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Mikael Morin <[email protected]>: https://gcc.gnu.org/g:6589f31a914e75161c0e098ec3e129d9b8c6011a commit r16-8907-g6589f31a914e75161c0e098ec3e129d9b8c6011a Author: Mikael Morin <[email protected]> Date: Thu May 7 20:48:26 2026 +0200 fortran: Add bounds checking code to the scalarizer block [PR125192] In gfc_conv_expr_descriptor, the array bounds checking code is added to the root block, which is a different block from the scalarizer block used to generate the array descriptor reference. This causes the array bounds checking code to come before, which can be problematic if the descriptor reference uses variables generated by the scalarizer, as they are used in bounds checking code before their definition in that case. This change adds the bounds checking code to the same block the scalarizer uses to generate the array descriptor reference, solving the use before definition problem. PR fortran/125192 PR fortran/125198 gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Add bounds checking code to the outermost loop's preliminary block. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_29.f90: New test. (cherry picked from commit 0c0c58310180b75a4ff23044006f7ddabe7f894c)
