https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84560
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- Created attachment 43513 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43513&action=edit Reduced translation unit. Bisecting the reduced translation unit points to r231952 (gcc 6.0.0) as the revision that introduced the ICE. r231952 | jason | 2015-12-24 22:24:51 -0500 (Thu, 24 Dec 2015) | 3 lines PR c++/69005 * call.c (add_template_candidate_real): Don't try to deduce X(X). Before that, GCC errors out with: pr84560.C: In instantiation of ‘struct __result_of_impl<false, false, function<void()>&>’: pr84560.C:77:61: required from ‘struct __invoke_result<function<void()>&>’ pr84560.C:79:66: required from ‘class result_of<function<void()>&()>’ pr84560.C:120:102: required by substitution of ‘template<class _Functor, class, class> function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = function<void()>; <template-parameter-1-2> = void; <template-parameter-1-3> = <missing>]’ pr84560.C:136:9: required from here pr84560.C:75:57: error: no matching function for call to ‘__result_of_impl<false, false, function<void()>&>::_S_test(int)’ typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ pr84560.C:72:147: note: candidate: template<class _Fn, class ... _Args> static __result_of_success<decltype (declval<_Fn>()((declval<_Args>)()...)), __invoke_other> __result_of_other_impl::_S_test(int) <decltype( declval<_Fn>()(declval<_Args>()...) ), __invoke_other> _S_test(int);