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 "