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

--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
The following additional patchlet does the trick.

Still need to regression test.

diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index 2fc9dfaf..8fef30ce 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -421,6 +421,12 @@ match_array_element_spec (gfc_array_spec *as)
   if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
     return AS_UNKNOWN;

+  if ((*upper)->expr_type == EXPR_CONSTANT && (*upper)->ts.type != BT_INTEGER)
+    {
+      gfc_error ("Expecting a scalar INTEGER expression at %C");
+      return AS_UNKNOWN;
+    }
+
   if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN
       && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0)
     {

Reply via email to