https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67133
--- Comment #27 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Martin Jambor from comment #26) > If fntype specifies the ABI then when we know we will be calling a > different function (which might have its prototype modified for > example by parameter removal), then we should set the fntype too. And > further inspection of cgraph_edge::redirect_call_stmt_to_callee also > suggests that is the correct thing. Therefore I'll bootstrap the > patch from comment #20 and propose it on the mailing list. > > While the committed patch does prevent the ICE, I would actually > prefer if gimple checking failed when it encounters a direct call with > mismatching fntype. It can't happen because of this bug but I suppose > we might get wrong-code generation if we get the type only slightly > wrong. For all calls the actuall call matters. Consider void my_memcpy (void); static const void *(ifn *)(void *, const void *, size_t) = (void (*)(void*,const void *, size_t)) memcpy; char a[10], b[10]; int main() { ifn (a, a, 10); } when we propagate 'my_memcpy' into the call (which we'll do) we need to retain the ABI to not expand bullshit. Forward declarations do not need to have the correct types. It's enough if the TU implementing my_memcpy has a signature matching the actual calls.