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

--- Comment #13 from Jürgen Reuter <juergen.reuter at desy dot de> ---
(In reply to GCC Commits from comment #9)
> The master branch has been updated by Mikael Morin <[email protected]>:
> 
> https://gcc.gnu.org/g:0c0c58310180b75a4ff23044006f7ddabe7f894c
> 
> commit r17-386-g0c0c58310180b75a4ff23044006f7ddabe7f894c
> 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.

This patch is shorter than the draft patch from comment #5, but I suppose it
does the same? Will test that patch against our code now.

Reply via email to