https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118441
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2025-01-15 --- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> --- It seems as if we need something like: --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -4244,2 +4244,4 @@ gfc_get_symbol_for_expr (gfc_expr * expr, bool sym->ts = expr->ts; + if (sym->ts.type == BT_CHARACTER) + sym->ts.u.cl = gfc_new_charlen (gfc_current_ns, expr->ts.u.cl); sym->attr.external = 1; A bit similar to what we are doing in gfc_copy_formal_args_intr, albeit I am not quite sure whether we should pass expr->ts.u.cl as second argument or not (and NULL). In principle, a function result needs to have a length, unless it is a deferred length (= allocatable or pointer) - thus, I pass expr->ts.u.cl (= length of the callee). It does not quite matter though, as ts.u.cl->length == NULL and it is set to PARM_DECL later.