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

kargl at gcc dot gnu.org changed:

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

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Thomas Koenig from comment #1)
> Should be easy to fix.

Likely, all of the gcc_assert()'s in gfc_simplify_reshape
should be gfc_error()'s.  This patch fixes the ICE for
this PR. (Watch for cut-n-paste tab corruption).

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c      (revision 276593)
+++ gcc/fortran/simplify.c      (working copy)
@@ -6762,7 +6762,15 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shap

          gfc_extract_int (e, &order[i]);

-         gcc_assert (order[i] >= 1 && order[i] <= rank);
+         if (order[i] < 1 || order[i] > rank)
+           {
+             gfc_error ("Element with a value of %d in ORDER at %L must be "
+                        "in the range [1, ..., %d] for the RESHAPE intrinsic "
+                        "near %L", order[i], &order_exp->where, rank,
+                        &shape_exp->where);
+             return &gfc_bad_expr;
+           }
+
          order[i]--;
          if (x[order[i]] != 0)
            {

Reply via email to