https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109788
--- Comment #12 from anlauf at gcc dot gnu.org --- (In reply to Jakub Jelinek from comment #11) > If you e.g. put breakpoint on the spot I changed and stopon the testcase > with -Os when t == global_trees[TI_VOID_LIST_NODE] you can then see in > e->callee the FUNCTION_TYPE with just 5 arguments. I am not too experienced to debug this kind of stuff, but I guess I've seen what happens. I was then wondering if one of the dump files would show the function decl, like we can see it for normal procedures, but did not succeed. The following (partial) patch seems to fix the decl: diff --git a/gcc/fortran/iresolve.cc b/gcc/fortran/iresolve.cc index 7880aba63bb..615d3ec98d4 100644 --- a/gcc/fortran/iresolve.cc +++ b/gcc/fortran/iresolve.cc @@ -2664,6 +2664,10 @@ gfc_resolve_spread (gfc_expr *f, gfc_expr *source, gfc_expr *dim, f->value.function.name = PREFIX ("spread"); } + /* Take formal argument type from SOURCE so that a function decl with the + right number of arguments is generated (hidden character length). */ + f->value.function.isym->formal->ts = source->ts; + if (dim && gfc_is_constant_expr (dim) && ncopies && gfc_is_constant_expr (ncopies) && source->shape[0]) { It would be interesting to see if you see issues with the following code: program p character(3) :: a = 'abc' real :: b = 42.0 complex :: c = (2.0,0.0) type t integer :: i end type t type(t) :: d = t(3) associate (y => spread(a,1,2) // "d") end associate associate (x => spread(b,1,2)) end associate associate (z => spread(c,1,2)) end associate associate (w => spread(d,1,2)) end associate end program p The library function _gfortran_spread_char_scalar should now have 6 arguments, while the uses of _gfortran_spread_scalar have 4 arguments, which are in part pointers to either intrinsic or user-defined types. I do hope that does not lead to new problems.