https://gcc.gnu.org/g:8ded56a52a79333ea0829d930254ec9c6f04db90
commit r16-4001-g8ded56a52a79333ea0829d930254ec9c6f04db90 Author: Paul Thomas <[email protected]> Date: Sat Sep 20 14:25:47 2025 +0100 Fortran: Fix regtest failure in pdt_48.f03. [PR83746] 2025-09-20 Paul Thomas <[email protected]> gcc/fortran PR fortran/83746 * trans-decl.cc (gfc_trans_deferred_vars): If a procedure with an non-allocatable, non-pointer explicit PDT result has no default initializer, the parameterized components should be allocated. Diff: --- gcc/fortran/trans-decl.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index f423dd728aaa..055698b1efdb 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -4831,6 +4831,23 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) } } + sym = (proc_sym->attr.function + && proc_sym != proc_sym->result) ? proc_sym->result : NULL; + + if (sym && !sym->attr.allocatable && !sym->attr.pointer + && sym->ts.type == BT_DERIVED + && sym->ts.u.derived + && !gfc_has_default_initializer (sym->ts.u.derived) + && sym->ts.u.derived->attr.pdt_type) + { + gfc_init_block (&tmpblock); + tmp = gfc_allocate_pdt_comp (sym->ts.u.derived, + sym->backend_decl, + sym->as ? sym->as->rank : 0, + sym->param_list); + gfc_add_expr_to_block (&tmpblock, tmp); + gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock), NULL); + } /* Initialize the INTENT(OUT) derived type dummy arguments. This should be done here so that the offsets and lbounds of arrays
