https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125267
--- Comment #13 from Mikael Morin <mikael at gcc dot gnu.org> ---
I confirm the comment #11 example is fixed by the patch for PR125192 on the 16
branch.
The problem is visible in the original tree dump of the function
pmatrix_normalize, which uses the variable D.4937 before it is defined:
if (D.4937->index.dim[1].lbound > D.4941)
{
_gfortran_runtime_error_at (&"At line 46 of file
comment_11.f90"[1]{lb: 1 sz: 1}, &"Index \'%ld\' of dimension 2 of array
\'pmatrix%%index\' outside of expected range (%ld:%ld)"[1]{lb: 1 sz: 1},
D.4941, D.4937->index.dim[1].lbound, D.4937->index.dim[1].ubound);
}
if (D.4937->index.dim[1].ubound < D.4941)
{
_gfortran_runtime_error_at (&"At line 46 of file
comment_11.f90"[1]{lb: 1 sz: 1}, &"Index \'%ld\' of dimension 2 of array
\'pmatrix%%index\' outside of expected range (%ld:%ld)"[1]{lb: 1 sz: 1},
D.4941, D.4937->index.dim[1].lbound, D.4937->index.dim[1].ubound);
}
D.4937 = pmatrix->_data;
The patch of PR125192 delays the two if blocks, so that the variable has been
defined when they use it.