https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103923
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The instantiation of unordered_map<K, int, H> instantiates this alias:
template<typename _Tp, typename _Hash>
using __cache_default
= __not_<__and_<// Do not cache for fast hasher.
__is_fast_hash<_Hash>,
// Mandatory to have erase not throwing.
__is_nothrow_invocable<const _Hash&, const _Tp&>>>;
That causes the instantiations of is_invocable<const H&, const K&> before the
types are complete, which gives the wrong answer. Then the value of that trait
is memoized by the compiler, and remains false when printed out in main().
I think this is technically undefined behaviour, because the standard says that
it's undefined to instantiate std::unordered_map (and most templates in
namespace std) with incomplete types. A nested class is not complete until the
enclosing class is complete.