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

--- Comment #9 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Following r256284 (PR 78534)  the original testcase ICE's. Interestingly, the
reduced testcases in #c2 and #c3 work fine.

The patch below fixes the ICE

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 533435a..82fe424 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -8392,7 +8392,9 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr
* expr2)
       if (expr1->ts.deferred)
        {
          if (expr2->expr_type != EXPR_NULL && lse.string_length != NULL)
-           gfc_add_modify (&block, lse.string_length, rse.string_length);
+           gfc_add_modify (&block, lse.string_length,
+                           fold_convert (TREE_TYPE (lse.string_length),
+                                         rse.string_length));
          else if (lse.string_length != NULL)
            gfc_add_modify (&block, lse.string_length,
                            build_zero_cst (TREE_TYPE (lse.string_length)));

Reply via email to