https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107022
Bug ID: 107022
Summary: error: use of deleted function 'std::unordered_map
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: piersh at hotmail dot com
Target Milestone: ---
this is a regression in newer point-releases of gcc (this bug got backported).
it appears first in 10.4, 11.2.1 and 12.x. 10.3 and 11.2.0 do not have this
issue.
#include <unordered_map>
#include <memory>
struct key {};
struct foo
{
struct my_hash
{
my_hash(int i = 42) {}
std::size_t operator()(const key &ep) const { return 0; }
};
private:
std::unordered_map<key, std::weak_ptr<std::string>, foo::my_hash>
things_{};
};
<source>:15:79: error: use of deleted function 'std::unordered_map<_Key, _Tp,
_Hash, _Pred, _Alloc>::unordered_map() [with _Key = key; _Tp =
std::weak_ptr<std::__cxx11::basic_string<char> >; _Hash = foo::my_hash; _Pred =
std::equal_to<key>; _Alloc = std::allocator<std::pair<const key,
std::weak_ptr<std::__cxx11::basic_string<char> > > >]'
15 | std::unordered_map<key, std::weak_ptr<std::string>, foo::my_hash>
things_{};
|
^
In file included from
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/unordered_map:47,
from <source>:1:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/unordered_map.h:141:7:
note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map()
[with _Key = key; _Tp = std::weak_ptr<std::__cxx11::basic_string<char> >; _Hash
= foo::my_hash; _Pred = std::equal_to<key>; _Alloc =
std::allocator<std::pair<const key,
std::weak_ptr<std::__cxx11::basic_string<char> > > >]' is implicitly deleted
because the default definition would be ill-formed:
141 | unordered_map() = default;
| ^~~~~~~~~~~~~
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/unordered_map.h:141:7:
error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc,
_ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy,
_Traits>::_Hashtable() [with _Key = key; _Value = std::pair<const key,
std::weak_ptr<std::__cxx11::basic_string<char> > >; _Alloc =
std::allocator<std::pair<const key,
std::weak_ptr<std::__cxx11::basic_string<char> > > >; _ExtractKey =
std::__detail::_Select1st; _Equal = std::equal_to<key>; _Hash = foo::my_hash;
_RangeHash = std::__detail::_Mod_range_hashing; _Unused =
std::__detail::_Default_ranged_hash; _RehashPolicy =
std::__detail::_Prime_rehash_policy; _Traits =
std::__detail::_Hashtable_traits<true, false, true>]'
In file included from
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/unordered_map:46:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/hashtable.h:529:7:
note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash,
_RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = key;
_Value = std::pair<const key, std::weak_ptr<std::__cxx11::basic_string<char> >
>; _Alloc = std::allocator<std::pair<const key,
std::weak_ptr<std::__cxx11::basic_string<char> > > >; _ExtractKey =
std::__detail::_Select1st; _Equal = std::equal_to<key>; _Hash = foo::my_hash;
_RangeHash = std::__detail::_Mod_range_hashing; _Unused =
std::__detail::_Default_ranged_hash; _RehashPolicy =
std::__detail::_Prime_rehash_policy; _Traits =
std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted
because the default definition would be ill-formed:
529 | _Hashtable() = default;
| ^~~~~~~~~~
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/hashtable.h:529:7:
error: use of deleted function 'constexpr
std::_Enable_default_constructor<false, _Tag>::_Enable_default_constructor()
[with _Tag = std::__detail::_Hash_node_base]'
In file included from
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/hashtable.h:36:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/enable_special_members.h:113:15:
note: declared here
113 | constexpr _Enable_default_constructor() noexcept = delete;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler returned: 1