[Bug fortran/125198] [16/17 regression] Bad code generated with -fcheck=bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125198 --- Comment #4 from GCC Commits --- The releases/gcc-16 branch has been updated by Mikael Morin : https://gcc.gnu.org/g:6589f31a914e75161c0e098ec3e129d9b8c6011a commit r16-8907-g6589f31a914e75161c0e098ec3e129d9b8c6011a Author: Mikael Morin 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)
[Bug fortran/125198] [16/17 regression] Bad code generated with -fcheck=bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125198 --- Comment #3 from GCC Commits --- The master branch has been updated by Mikael Morin : https://gcc.gnu.org/g:0c0c58310180b75a4ff23044006f7ddabe7f894c commit r17-386-g0c0c58310180b75a4ff23044006f7ddabe7f894c Author: Mikael Morin 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.
[Bug fortran/125198] [16/17 regression] Bad code generated with -fcheck=bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125198 Steve Kargl changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #2 from Steve Kargl --- (In reply to Steve Kargl from comment #1) > Neil, thanks for reporting the issue. > This may be the same issue as reported in PR 125192. Mikael's patch from comment #5 in PR 125192 fixes this issues. So, yes, a duplicate of 125192. Thanks for the report Neil. *** This bug has been marked as a duplicate of bug 125192 ***
[Bug fortran/125198] [16/17 regression] Bad code generated with -fcheck=bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125198 Richard Biener changed: What|Removed |Added Summary|[16 regression] Bad code|[16/17 regression] Bad code |generated with |generated with |-fcheck=bounds |-fcheck=bounds Priority|P3 |P4 Keywords||wrong-code Target Milestone|--- |16.2
