[Bug fortran/93364] [9/10 Regression] ICE in gfc_set_array_spec, at fortran/array.c:879

anlauf at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 19 19:30:43 GMT 2020


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

anlauf at gcc dot gnu.org changed:

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
The following patch would avoid the ICE:

diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index 57972bc9176..471523fb767 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -864,6 +864,10 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as,
locus *error_loc)
       return false;
     }

+  /* Check F2018:C822.  */
+  if (sym->as->rank + sym->as->corank > GFC_MAX_DIMENSIONS)
+    goto too_many;
+
   if (as->corank)
     {
       sym->as->cotype = as->cotype;

I have a gut feeling that this kind of check should trigger earlier,
but cannot find this place.


More information about the Gcc-bugs mailing list