public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107340] New: std::unordered_map and completeness of nested classes
@ 2022-10-21 7:19 jens.maurer at gmx dot net
2022-10-21 7:24 ` [Bug c++/107340] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jens.maurer at gmx dot net @ 2022-10-21 7:19 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/107340] std::unordered_map and completeness of nested classes
2022-10-21 7:19 [Bug c++/107340] New: std::unordered_map and completeness of nested classes jens.maurer at gmx dot net
@ 2022-10-21 7:24 ` 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
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107340
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 107022.
*** This bug has been marked as a duplicate of bug 107022 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/107340] std::unordered_map and completeness of nested classes
2022-10-21 7:19 [Bug c++/107340] New: std::unordered_map and completeness of nested classes jens.maurer at gmx dot net
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
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 7:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107340
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also nested classes are completed at the end of the outer most class.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/107340] std::unordered_map and completeness of nested classes
2022-10-21 7:19 [Bug c++/107340] New: std::unordered_map and completeness of nested classes jens.maurer at gmx dot net
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
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-21 10:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107340
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And the standard says it's undefined to use incomplete classes with
unordered_map.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-21 10:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 7:19 [Bug c++/107340] New: std::unordered_map and completeness of nested classes jens.maurer at gmx dot net
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
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).