public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/115420] Default constructor of unordered_map deleted
Date: Tue, 11 Jun 2024 09:41:56 +0000 [thread overview]
Message-ID: <bug-115420-4-JUsKlkZpKy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-115420-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115420
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Last reconfirmed| |2024-06-11
Status|CLOSED |NEW
Ever confirmed|0 |1
Resolution|INVALID |---
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If we add this to _Hashtable:
template<typename>
struct _Check_hash_requirements : true_type
{
static_assert(is_copy_constructible<_Hash>::value,
"custom hash function must be copy constructible");
static_assert(is_destructible<_Hash>::value,
"custom hash function must be destructible");
};
template<typename _Tp>
struct _Check_hash_requirements<hash<_Tp>> : true_type
{
static_assert(is_default_constructible<hash<_Tp>>::value,
"the std::hash<key_type> specialization is disabled");
};
static_assert(_Check_hash_requirements<_Hash>::value, "");
Then the first error is much clearer where the problem lies:
In file included from
/home/jwakely/gcc/15/include/c++/15.0.0/bits/unordered_map.h:33,
from /home/jwakely/gcc/15/include/c++/15.0.0/unordered_map:41,
from un.cc:1:
/home/jwakely/gcc/15/include/c++/15.0.0/bits/hashtable.h: In instantiation of
'struct std::_Hashtable<std::__cxx11::basic_string<char>, std::pair<const
std::__cxx11::basic_string<char>, long unsigned int>,
std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned
int> >, std::__detail::_Select1st,
std::equal_to<std::__cxx11::basic_string<char> >,
std::hash<std::__cxx11::basic_string<char> >,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true,
false, true>
>::_Check_hash_requirements<std::hash<std::__cxx11::basic_string<char> > >':
/home/jwakely/gcc/15/include/c++/15.0.0/bits/hashtable.h:221:54: required
from 'class std::_Hashtable<std::__cxx11::basic_string<char>, std::pair<const
std::__cxx11::basic_string<char>, long unsigned int>,
std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned
int> >, std::__detail::_Select1st,
std::equal_to<std::__cxx11::basic_string<char> >,
std::hash<std::__cxx11::basic_string<char> >,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true,
false, true> >'
221 | static_assert(_Check_hash_requirements<_Hash>::value, "");
| ^~~~~
/home/jwakely/gcc/15/include/c++/15.0.0/bits/unordered_map.h:112:18: required
from 'class std::unordered_map<std::__cxx11::basic_string<char>, long unsigned
int>'
112 | _Hashtable _M_h;
| ^~~~
un.cc:5:45: required from here
5 | std::unordered_map<std::string, uint64_t> bar;
| ^~~
/home/jwakely/gcc/15/include/c++/15.0.0/bits/hashtable.h:218:62: error: static
assertion failed: the std::hash<key_type> specialization is disabled
218 | static_assert(is_default_constructible<hash<_Tp>>::value,
| ^~~~~
So let's reopen this as a diagnostic RFE for the library.
next prev parent reply other threads:[~2024-06-11 9:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 17:20 [Bug c++/115420] New: " krebbel at gcc dot gnu.org
2024-06-10 17:23 ` [Bug libstdc++/115420] " pinskia at gcc dot gnu.org
2024-06-11 5:46 ` krebbel at gcc dot gnu.org
2024-06-11 5:47 ` krebbel at gcc dot gnu.org
2024-06-11 7:08 ` xry111 at gcc dot gnu.org
2024-06-11 9:41 ` redi at gcc dot gnu.org [this message]
2024-06-11 9:44 ` redi at gcc dot gnu.org
2024-06-11 9:55 ` redi at gcc dot gnu.org
2024-06-13 13:10 ` cvs-commit at gcc dot gnu.org
2024-06-13 13:14 ` redi at gcc dot gnu.org
2024-06-25 10:59 ` redi at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-115420-4-JUsKlkZpKy@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).