public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jens.maurer at gmx dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107340] New: std::unordered_map and completeness of nested classes Date: Fri, 21 Oct 2022 07:19:57 +0000 [thread overview] Message-ID: <bug-107340-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107340 Bug ID: 107340 Summary: std::unordered_map and completeness of nested classes Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jens.maurer at gmx dot net Target Milestone: --- Consider: #include <unordered_map> struct X { struct Key { int x = 0; bool operator==(const Key&) const = default; std::size_t operator()(const Key& k) const noexcept { return k.x; } }; int a[sizeof(Key)]; std::unordered_map<Key, std::size_t, Key> m; }; X x; When compiled with "g++ -std=c++20", it yields: a1.cc:24:3: error: use of deleted function ‘X::X()’ (plus lots of details) since gcc 11.3 and 12.x; gcc 11.2 compiled this code fine. Analysis: The nested class "X::Key" is complete at its closing brace, also evidenced by the array data member declaration. Yet, "m" attains a deleted default constructor for no apparent reason. Moving class "Key" to namespace scope or providing a separate, but still nested, "X::KeyHash" class works around the issue.
next reply other threads:[~2022-10-21 7:19 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-21 7:19 jens.maurer at gmx dot net [this message] 2022-10-21 7:24 ` [Bug c++/107340] " pinskia at gcc dot gnu.org 2022-10-21 7:26 ` pinskia at gcc dot gnu.org 2022-10-21 10:51 ` 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-107340-4@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: linkBe 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).