]> git.ipfire.org Git - thirdparty/gcc.git/commit - libstdc++-v3/testsuite/20_util/unique_ptr/hash/90388.cc
PR libstdc++/90388 fix std::hash<unique_ptr<T,D>> bugs
authorJonathan Wakely <jwakely@redhat.com>
Fri, 10 May 2019 21:41:16 +0000 (22:41 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 10 May 2019 21:41:16 +0000 (22:41 +0100)
commit7fb65a875956bac7095c17c545f2bfa131209f50
tree0d945d627e2583d50ac319f8f646456033b25a85
parent302b6996078bca83fbb51e7b77bce9fbb4e8072b
PR libstdc++/90388 fix std::hash<unique_ptr<T,D>> bugs

A disabled specialization should not be callable, so move the function
call operator into a new base class which correctly implements the
disabled hash semantics. For the versioned namespace configuration do
not derive from __poison_hash in the enabled case, as the empty base
class serves no purpose but potentially increases the object size. For
the default configuration that base class must be kept, to preserve
layout.

An enabled specialization should not be unconditionally noexcept,
because the underlying hash object might throw.

PR libstdc++/90388
* include/bits/unique_ptr.h (default_delete, default_delete<T[]>):
Use _Require for constraints.
(operator>(nullptr_t, const unique_ptr<T,D>&)): Implement exactly as
per the standard.
(__uniq_ptr_hash): New base class with conditionally-disabled call
operator.
(hash<unique_ptr<T,D>>): Derive from __uniq_ptr_hash.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
* testsuite/20_util/unique_ptr/hash/90388.cc: New test.

From-SVN: r271078
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/unique_ptr.h
libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
libstdc++-v3/testsuite/20_util/unique_ptr/hash/90388.cc [new file with mode: 0644]