https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113866
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-valid-code CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- Argument passing and the handling of optional arguments differs for bind(c) procedures from regular ones. For character, the length is not passed as a hidden argument but in the CFI descriptor. Tentative partial fix for comment#1: diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 67abca9f6ba..42ef1cd271d 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7270,7 +7271,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, an intrinsic subroutine, however, fsym is NULL, but we might still have an optional argument, so we proceed to the substitution just in case. */ - if (e && (fsym == NULL || fsym->attr.optional)) + if (e && (fsym == NULL || fsym->attr.optional) + && !sym->attr.is_bind_c) { /* If an optional argument is itself an optional dummy argument, check its presence and substitute a null if absent. This is Likely incomplete; needs checking using variations of dummy and actual args.