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

Harald Anlauf <anlauf at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #3 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
This fixes the ICE with the original testcase as well as the reduced ones:

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 7cbb2b01c19..4472cdd617f 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -8013,6 +8013,17 @@ get_array_charlen (gfc_expr *expr, gfc_se *se)
       break;

     case EXPR_FUNCTION:
+      /* The result length of some elemental intrinsics might already be set
in
+        the function result's backend_decl.  */
+      if (expr->ts.u.cl->length == NULL
+         && (expr->value.function.isym->id == GFC_ISYM_ADJUSTL
+             || expr->value.function.isym->id == GFC_ISYM_ADJUSTR))
+       {
+         expr->ts.u.cl->backend_decl
+           = expr->value.function.actual->expr->ts.u.cl->backend_decl;
+         break;
+       }
+
       if (expr->value.function.esym == NULL
            || expr->ts.u.cl->length->expr_type == EXPR_CONSTANT)
        {

This works simply because it breaks the recursion.  It does fail for

  call bar(adjustl(x(:)(1:)))

Reply via email to