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

--- Comment #12 from markeggleston at gcc dot gnu.org ---
Created attachment 48155
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48155&action=edit
Proposed fix

Sorry for the duplicate (PR94430) I missed this PR.

The cause of the errors messages is due to most of the code in expr.c
introduced by PR93600 being deleted.

I restored the code, the error went away, however, bessel_5_redux.f90 resulted
in an ICE.

When this bit of PR94246 is put back:

@@ -2314,9 +2296,8 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
   gfc_constructor_base ctor;
   gfc_constructor *args[5] = {};  /* Avoid uninitialized warnings.  */
   gfc_constructor *ci, *new_ctor;
-  gfc_expr *expr, *old;
+  gfc_expr *expr, *old, *p;
   int n, i, rank[5], array_arg;
-  int errors = 0;

   if (e == NULL)
     return false;
@@ -2384,8 +2365,6 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
       n++;
     }

-  gfc_get_errors (NULL, &errors);
-
   /* Using the array argument as the master, step through the array
      calling the function for each element and advancing the array
      constructors together.  */
@@ -2419,8 +2398,12 @@ scalarize_intrinsic_call (gfc_expr *e, bool init_flag)
       /* Simplify the function calls.  If the simplification fails, the
         error will be flagged up down-stream or the library will deal
         with it.  */
-      if (errors == 0)
-       gfc_simplify_expr (new_ctor->expr, 0);
+      p = gfc_copy_expr (new_ctor->expr);
+
+      if (!gfc_simplify_expr (p, init_flag))
+       gfc_free_expr (p);
+      else
+       gfc_replace_expr (new_ctor->expr, p);

       for (i = 0; i < n; i++)
        if (args[i])

bessel_5_redux.f90.

I think

      if (errors == 0)
        gfc_simplify_expr (new_ctor->expr, 0);

caused the ICE.

I'm preparing the patch for upstream, its commit message needs updating not
that I have a PR number.

Reply via email to