https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125192
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #5)
> (In reply to anlauf from comment #3)
> > Might be related to PR124661.
>
> (In reply to anlauf from comment #4)
> > Mikael, can you please have a look at this one?
>
> Indeed, this is a fallout of:
> r16-2371-g8f41c87654fd819e48c9f6f1ac3d87e35794d310
> fortran: Factor array descriptor references
> similar to PR124661.
> Once again the new variable is used before it is defined.
>
> In this case, gfc_conv_expr_descriptor's bound checking adds code to the
> root block, but the array descriptor is defined by the scalarizer, so it's
> defined in the loop block which is appended to the root block at the end.
>
> Draft patch:
>
> diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
> index 4ab1d04440d..d633d70e707 100644
> --- a/gcc/fortran/trans-array.cc
> +++ b/gcc/fortran/trans-array.cc
> @@ -8639,7 +8639,12 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
>
> /* Add bounds-checking for elemental dimensions. */
> if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) && !expr->no_bounds_check)
> - array_bound_check_elemental (se, ss, expr);
> + {
> + gfc_se bnd_ck_se;
> + gfc_init_se (&bnd_ck_se, nullptr);
> + array_bound_check_elemental (&bnd_ck_se, ss, expr);
> + gfc_add_block_to_block (&outermost_loop (&loop)->pre, &bnd_ck_se.pre);
> + }
>
> if (need_tmp)
> {
>
>
> Taking.
Steve thinks that pr125198 is a duplicate of this one. If nothing else, I would
suspect that it has a common cause.
Best regards
Paul