https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117387
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> --- Like this? diff --git a/gcc/calls.cc b/gcc/calls.cc index f67067acad4..1df064dcef6 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -2992,8 +2992,6 @@ expand_call (tree exp, rtx target, int ignore) Normally, don't include the last named arg if anonymous args follow. We do include the last named arg if targetm.calls.strict_argument_naming() returns nonzero. - (If no anonymous args follow, the result of list_length is actually - one too large. This is harmless.) If targetm.calls.pretend_outgoing_varargs_named() returns nonzero, and targetm.calls.strict_argument_naming() returns zero, @@ -3008,7 +3006,8 @@ expand_call (tree exp, rtx target, int ignore) if ((type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype)) && targetm.calls.strict_argument_naming (args_so_far)) - ; + /* Don't include the last named arg for non-variadic function. */ + n_named_args -= !stdarg_p (funtype); else if (type_arg_types != 0 && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)) /* Don't include the last named arg. */ -- 2.47.0