https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78661
--- Comment #8 from janus at gcc dot gnu.org --- This patch seems to produce the correct dump for the example in comment 7: Index: gcc/fortran/trans-io.c =================================================================== --- gcc/fortran/trans-io.c (revision 243773) +++ gcc/fortran/trans-io.c (working copy) @@ -1713,6 +1713,32 @@ transfer_namelist_element (stmtblock_t * block, co vtable = gfc_build_addr_expr (pvoid_type_node, vtable); } } + else if (ts->type == BT_CLASS) + { + gfc_symbol *derived = ts->u.derived->components->ts.u.derived; + gfc_symtree *tb_io_st = gfc_find_typebound_dtio_proc (derived, + last_dt == WRITE, true); + if (tb_io_st) + { + gfc_se se; + gfc_symtree *st = gfc_find_symtree (sym->ns->sym_root, sym->name); + // build vtable expr + gfc_expr *expr = gfc_get_variable_expr (st); + gfc_add_vptr_component (expr); + gfc_init_se (&se, NULL); + se.want_pointer = 1; + gfc_conv_expr (&se, expr); + vtable = se.expr; + // build dtio expr + gfc_add_component_ref (expr, + tb_io_st->n.tb->u.generic->specific_st->name); + gfc_init_se (&se, NULL); + se.want_pointer = 1; + gfc_conv_expr (&se, expr); + gfc_free_expr (expr); + dtio_proc = se.expr; + } + } if (ts->type == BT_CHARACTER) tmp = ts->u.cl->backend_decl; The library call with this looks like: _gfortran_st_set_nml_dtio_var (&dt_parm.3, &x, &"x"[1]{lb: 1 sz: 1}, 0, 0, 56, x._vptr->write_formatted, (struct __vtype_m_T *) x._vptr); That seems correct to me, but still the output is wrong: &NML X=� / So I guess something in the library still fails, and I already have a suspicion ...