https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84615
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #15 from kargl at gcc dot gnu.org --- (In reply to Janne Blomqvist from comment #12) > So to be clear, the problem seems to be that while the code generation for > the function itself appears Ok, it generates the interface wrong (i.e. uses > the declared charlen kind instead of C_SIZE_T), and thus calling it doesn't > work properly. > > I still have no idea where in the frontend code the error is. I haven't looked, but suspect that you can force a conversion to the correct charlen in trans-intrinsic.c:gfc_conv_intrinsic_function_args Well, for intrinsics, the above function has if (e->ts.type == BT_CHARACTER) { gfc_conv_expr (&argse, e); gfc_conv_string_parameter (&argse); argarray[curr_arg++] = argse.string_length; gcc_assert (curr_arg < nargs); } From trans-expr.c, one has /* Makes sure se is suitable for passing as a function string parameter. */ /* TODO: Need to check all callers of this function. It may be abused. */ void gfc_conv_string_parameter (gfc_se * se) I suspect you can do a fold_convert here or a conversion before the gfc_conv_expr.