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

--- Comment #17 from janus at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #16)
> Index: resolve.c
> ===================================================================
> --- resolve.c   (revision 243227)
> +++ resolve.c   (working copy)
> @@ -12010,6 +12010,9 @@ resolve_fl_procedure (gfc_symbol *sym, i
>      {
>        gfc_charlen *cl = sym->ts.u.cl;
>  
> +      if (strcmp (sym->name, "__convert_s4_s1") == 0)
> +       return false;
> +
>        if (cl && cl->length && gfc_is_constant_expr (cl->length)
>              && !resolve_charlen (cl))
>         return false;
> 
> It's not pretty, but seems to work. :(

I don't really think that sort of workaround is a good idea.

Maybe one can instead try to nullify the memory in gfc_free charlen, so that we
at least know that cl->lengh is not a valid pointer? (Something similar is also
done in gfc_free_expr / free_expr0 in expr.c.)

Index: symbol.c
===================================================================
--- symbol.c    (revision 243224)
+++ symbol.c    (working copy)
@@ -3838,6 +3838,7 @@ gfc_free_charlen (gfc_charlen *cl, gfc_charlen *en

       cl2 = cl->next;
       gfc_free_expr (cl->length);
+      memset (cl, '\0', sizeof (gfc_charlen));
       free (cl);
     }
 }

Steve, could you check if this fixes the ICE?

Reply via email to