https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93631
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Just to add as a data point, gimple_builtin_call_types_compatible_p was originally added to catch indirect calls turned into direct calls of builtins but with wrongly typed args like from void (*fn)(int) = (void (*)(int))&memcpy; fn (1); it was _not_ designed to cope with a function decl that claims to be BUILT_IN_MEMCPY but whose TYPE_ARG_TYPES are not compatible with what we'd expect from a memcpy declaration. It is the frontends business to make sure the middle-end is not seeing a DECL_FUNCTION_CODE when the types do not match the canonical function declaration. The patch from comment#3 is a hack trying to work around FEs brokeness. But it's the frontends that need fixing. Finally. Please. Iff then as hackish as comment#3 but please within the FE like in merge_decls at the end do if (DECL_FUNCTION_CODE (...) && !decls_compatible_p (builtin_decl_explicit (...), ...))) DECL_BUILT_IN_CLASS (..) = BUILT_IN_NONE; and possibly clear the decl from builtin_decl_implicit iff we ever populated that with user decls.