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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |janus at gcc dot gnu.org

--- Comment #5 from janus at gcc dot gnu.org ---
I'm now testing the following patch, which fixes the problem:


diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 4ad4dcf780d..ac054483e0e 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -9272,7 +9272,6 @@ resolve_select_type (gfc_code *code, gfc_namespace
*old_ns)
 static void
 resolve_transfer (gfc_code *code)
 {
-  gfc_typespec *ts;
   gfc_symbol *sym, *derived;
   gfc_ref *ref;
   gfc_expr *exp;
@@ -9308,7 +9307,9 @@ resolve_transfer (gfc_code *code)
                                    _("item in READ")))
     return;

-  ts = exp->expr_type == EXPR_STRUCTURE ? &exp->ts : &exp->symtree->n.sym->ts;
+  const gfc_typespec *ts = exp->expr_type == EXPR_STRUCTURE
+                       || exp->expr_type == EXPR_FUNCTION
+                        ? &exp->ts : &exp->symtree->n.sym->ts;

   /* Go to actual component transferred.  */
   for (ref = exp->ref; ref; ref = ref->next)

Reply via email to