https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90388

            Bug ID: 90388
           Summary: Disabled hash specialization should not be invocable
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

[unord.hash] p4 says "Disabled specializations of hash are not function object
types" but we fail to follow that:

#include <memory>

struct D {
  struct pointer { pointer(int*) { } };
  void operator()(pointer) const noexcept { }
};

int main()
{
  static_assert( !std::is_invocable_v<std::hash<D::pointer>&, D::pointer> );

  using UP = std::unique_ptr<int, D>;
  static_assert( !std::is_invocable_v<std::hash<UP>&, UP> );
}

h.cc: In function 'int main()':
h.cc:13:18: error: static assertion failed
   13 |   static_assert( !std::is_invocable_v<std::hash<UP>&, UP> );
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Also, hash<UP>::operator() should not be unconditionally noexcept, because (if
it is enabled) hash<UP::pointer>::operator() might throw ([util.smartptr.hash]
p1).

Reply via email to