https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71544
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW Component|tree-optimization |fortran --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed as fortran FE bug. The FE manages to set ".r" as fn spec attribute on save_cptr which specifies that its first argument does not escape. It's trans-types.c:create_fn_spec that does this by doing for (f = gfc_sym_get_dummy_args (sym); f; f = f->next) if (spec_len < sizeof (spec)) { if (!f->sym || f->sym->attr.pointer || f->sym->attr.target || f->sym->attr.external || f->sym->attr.cray_pointer || (f->sym->ts.type == BT_DERIVED && (f->sym->ts.u.derived->attr.proc_pointer_comp || f->sym->ts.u.derived->attr.pointer_comp)) || (f->sym->ts.type == BT_CLASS && (CLASS_DATA (f->sym)->ts.u.derived->attr.proc_pointer_comp || CLASS_DATA (f->sym)->ts.u.derived->attr.pointer_comp))) spec[spec_len++] = '.'; else if (f->sym->attr.intent == INTENT_IN) spec[spec_len++] = 'r'; else if (f->sym) spec[spec_len++] = 'w'; } and it looks like the side-effect of marking arguments as not escaping as soon as you specify anything else than . was overlooked. Or Fortran really doesn't allow args to be stored away but has an exception for C binding types which needs handling above.