[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 29 22:47:00 GMT 2017


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

--- Comment #3 from kargl at gcc dot gnu.org ---
% svn diff resolve.c 
Index: resolve.c
===================================================================
--- resolve.c   (revision 253236)
+++ resolve.c   (working copy)
@@ -7387,8 +7387,14 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bo
   if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred
       && !UNLIMITED_POLY (e))
     {
-      int cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
-                                     code->ext.alloc.ts.u.cl->length);
+      int cmp;
+
+      if (!e->ts.u.cl->length)
+       goto failure;
+
+      cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
+                                 code->ext.alloc.ts.u.cl->length);
+
       if (cmp == 1 || cmp == -1 || cmp == -3)
        {
          gfc_error ("Allocating %s at %L with type-spec requires the same "


More information about the Gcc-bugs mailing list