http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53329
Bug #: 53329 Summary: ICE with deferred-length module variables Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Blocks: 45170 The following code gives an ICE: module m character(len=:), allocatable :: str end module m Untested fix: --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1103,2 +1103,10 @@ gfc_create_string_length (gfc_symbol * sym) sym->ts.u.cl->backend_decl = length; + + if (sym->attr.save + || (ns->parent && ns->parent->proc_name->attr.flavor == FL_MODULE)) + TREE_STATIC (length) = 1; + + if (ns->parent && ns->parent->proc_name->attr.flavor == FL_MODULE + && (sym->attr.access != ACCESS_PRIVATE || sym->attr.public_used)) + TREE_PUBLIC (length) = 1; }