Fix another UBSAN in Fortran coarray.
authorMartin Liska <mliska@suse.cz>
Thu, 24 Oct 2019 08:49:02 +0000 (10:49 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 24 Oct 2019 08:49:02 +0000 (08:49 +0000)
2019-10-24  Martin Liska  <mliska@suse.cz>

PR fortran/92174
* array.c (gfc_resolve_array_spec): Break the loop
for out of bounds index.
* resolve.c (is_non_constant_shape_array): Likewise.

From-SVN: r277367

gcc/fortran/ChangeLog
gcc/fortran/array.c
gcc/fortran/resolve.c

index 5bb04d779eb979aacf24d4cf48686e9b31d5db50..4e3910298b61def5b32e2c3f8507005272bb319d 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-24  Martin Liska  <mliska@suse.cz>
+
+       PR fortran/92174
+       * array.c (gfc_resolve_array_spec): Break the loop
+       for out of bounds index.
+       * resolve.c (is_non_constant_shape_array): Likewise.
+
 2019-10-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        dump-parse-tree.c (show_expr): Add dumping of BT_BOZ constants.
index f0980dd9cefae783c2f807ff7a6e6034392ba6e4..36223d2233daabc0e7b788ffa187aa91a1ca548e 100644 (file)
@@ -410,6 +410,9 @@ gfc_resolve_array_spec (gfc_array_spec *as, int check_constant)
 
   for (i = 0; i < as->rank + as->corank; i++)
     {
+      if (i == GFC_MAX_DIMENSIONS)
+       return false;
+
       e = as->lower[i];
       if (!resolve_array_bound (e, check_constant))
        return false;
index 93f2d0aa7612c74a10998b394cb721e9c9a40086..5deeb4fc87b0b62f2412d1b7b8977605deb111a9 100644 (file)
@@ -12266,6 +12266,9 @@ is_non_constant_shape_array (gfc_symbol *sym)
         simplification now.  */
       for (i = 0; i < sym->as->rank + sym->as->corank; i++)
        {
+         if (i == GFC_MAX_DIMENSIONS)
+           break;
+
          e = sym->as->lower[i];
          if (e && (!resolve_index_expr(e)
                    || !gfc_is_constant_expr (e)))