public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107022] New: error: use of deleted function 'std::unordered_map
@ 2022-09-23 21:58 piersh at hotmail dot com
  2022-09-23 22:00 ` [Bug c++/107022] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: piersh at hotmail dot com @ 2022-09-23 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-21 15:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 21:58 [Bug c++/107022] New: error: use of deleted function 'std::unordered_map piersh at hotmail dot com
2022-09-23 22:00 ` [Bug c++/107022] " pinskia at gcc dot gnu.org
2022-09-23 22:05 ` pinskia at gcc dot gnu.org
2022-09-23 22:14 ` redi at gcc dot gnu.org
2022-09-23 22:16 ` piersh at hotmail dot com
2022-09-23 22:21 ` piersh at hotmail dot com
2022-09-23 22:22 ` pinskia at gcc dot gnu.org
2022-10-21  7:24 ` pinskia at gcc dot gnu.org
2022-10-21 14:03 ` jens.maurer at gmx dot net
2022-10-21 15:08 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).