https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70929
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- I wonder why we don't simply do the following, which checks the type of the originally built CALL_EXPR from the frontends which should have done the job of matching up the actual arguments closely enough with the type of the actual function called. Also fixes the testcase (obviously). Index: gcc/cgraph.c =================================================================== --- gcc/cgraph.c (revision 244897) +++ gcc/cgraph.c (working copy) @@ -3733,17 +3733,8 @@ bool gimple_check_call_matching_types (gimple *call_stmt, tree callee, bool args_count_match) { - tree lhs; - - if ((DECL_RESULT (callee) - && !DECL_BY_REFERENCE (DECL_RESULT (callee)) - && (lhs = gimple_call_lhs (call_stmt)) != NULL_TREE - && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), - TREE_TYPE (lhs)) - && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) - || !gimple_check_call_args (call_stmt, callee, args_count_match)) - return false; - return true; + return types_compatible_p (gimple_call_fntype (call_stmt), + TREE_TYPE (callee)); } /* Reset all state within cgraph.c so that we can rerun the compiler