[Bug libstdc++/90388] Disabled hash specialization should not be invocable
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 10 21:41:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90388
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Fri May 10 21:41:16 2019
New Revision: 271078
URL: https://gcc.gnu.org/viewcvs?rev=271078&root=gcc&view=rev
Log:
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.
Added:
trunk/libstdc++-v3/testsuite/20_util/unique_ptr/hash/90388.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/unique_ptr.h
trunk/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc
More information about the Gcc-bugs
mailing list