// { dg-do compile { target c++17 } } #include struct S { }; // std::hash is a disabled specialization. template> constexpr std::size_t hash_size = sizeof(std::hash>); template struct MultiHash : std::hash>... { }; #if _GLIBCXX_INLINE_VERSION // For the unstable ABI the size should always be one. template constexpr bool check_hash_size = sizeof(MultiHash) == 1; #else // For the default ABI, each std::hash> specialization // has a base class of type __hash_empty_base and if // the same type occurs more than once they must have unique addresses. template constexpr bool check_hash_size = sizeof(MultiHash) == Size; #endif // All these types have distinct D::pointer types, so no duplicate base classes static_assert( check_hash_size<1, int>, "" ); static_assert( check_hash_size<1, int, long, double>, "" ); static_assert( check_hash_size<1, int, const int>, "" ); static_assert( check_hash_size<1, int, long, const int>, "" ); // Likewise for these disabled specializations: static_assert( check_hash_size<1, S>, "" ); static_assert( check_hash_size<1, int, S>, "" ); static_assert( check_hash_size<1, int, S, const int>, "" ); static_assert( check_hash_size<1, int, S, const int, const S>, "" ); static_assert( check_hash_size<1, int, S, const S, const int>, "" ); // But this has two base classes of type __hash_empty_base: static_assert( check_hash_size<2, int, int[]>, "" ); static_assert( check_hash_size<2, int, int[], const int>, "" ); // And this has two base classes of type __hash_not_enabled: static_assert( check_hash_size<2, S, S[]>, "" ); static_assert( check_hash_size<2, S, S[], const S>, "" ); struct Del : std::default_delete { }; using P = std::unique_ptr; using PD = std::unique_ptr; using PC = std::unique_ptr>; using PA = std::unique_ptr; struct HashClash : std::hash

, std::hash, std::hash, std::hash { }; #if _GLIBCXX_INLINE_VERSION static_assert(sizeof(HashClash) == 1, "No duplicate bases for unstable ABI"); #else static_assert(sizeof(HashClash) == 4, "four __hash_empty_base bases"); #endif struct Del2 : std::default_delete { using pointer = const int*; }; using PD2 = std::unique_ptr; struct Hash2 : std::hash, std::hash { }; static_assert(sizeof(Hash2) == 1, "No duplicate bases");