public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105717] New: [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type
@ 2022-05-24 10:29 redi at gcc dot gnu.org
2022-05-24 10:30 ` [Bug libstdc++/105717] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-24 10:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105717
Bug ID: 105717
Summary: [9/10/11/12/13 Regression] cannot create unordered_map
from range of types convertible to value_type
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: unassigned at gcc dot gnu.org
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #56112 +++
François observed that I fixed construction for PR 56112, but we still don't
support insertion of such types:
#include <unordered_map>
#include <utility>
#include <assert.h>
struct Key
{
explicit Key(const int* p) : value(p) { }
~Key() { value = nullptr; }
bool operator==(const Key& k) const
{ return *value == *k.value; }
const int* value;
};
struct hash
{
std::size_t operator()(const Key& k) const noexcept
{ return *k.value; }
};
struct S
{
static int _count;
int value;
operator std::pair<const Key, int>() const
{
++_count;
return { Key(&value), value };
}
};
int S::_count = 0;
int main()
{
S s[1] = { {2} };
std::unordered_map<Key, int, hash> m(s, s + 1);
assert( S::_count == 1 );
std::unordered_multimap<Key, int, hash> mm(s, s + 1);
assert( S::_count == 2 );
m.insert(s, s + 1);
assert( S::_count == 3 );
mm.insert(s, s + 1);
assert( S::_count == 4 );
}
This worked in 4.7
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/105717] [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type
2022-05-24 10:29 [Bug libstdc++/105717] New: [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type redi at gcc dot gnu.org
@ 2022-05-24 10:30 ` redi at gcc dot gnu.org
2022-05-24 12:36 ` rguenth at gcc dot gnu.org
2022-06-15 18:30 ` [Bug libstdc++/105717] [10/11/12/13 " fdumont at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-24 10:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105717
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|unassigned at gcc dot gnu.org |
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-05-24
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/105717] [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type
2022-05-24 10:29 [Bug libstdc++/105717] New: [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type redi at gcc dot gnu.org
2022-05-24 10:30 ` [Bug libstdc++/105717] " redi at gcc dot gnu.org
@ 2022-05-24 12:36 ` rguenth at gcc dot gnu.org
2022-06-15 18:30 ` [Bug libstdc++/105717] [10/11/12/13 " fdumont at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-24 12:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105717
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/105717] [10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type
2022-05-24 10:29 [Bug libstdc++/105717] New: [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type redi at gcc dot gnu.org
2022-05-24 10:30 ` [Bug libstdc++/105717] " redi at gcc dot gnu.org
2022-05-24 12:36 ` rguenth at gcc dot gnu.org
@ 2022-06-15 18:30 ` fdumont at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: fdumont at gcc dot gnu.org @ 2022-06-15 18:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105717
François Dumont <fdumont at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|10.4 |13.0
CC| |fdumont at gcc dot gnu.org
Resolution|--- |FIXED
Assignee|unassigned at gcc dot gnu.org |fdumont at gcc dot gnu.org
--- Comment #1 from François Dumont <fdumont at gcc dot gnu.org> ---
libstdc++: [_Hashtable] Insert range of types convertible to value_type PR
105717
Fix insertion of range of instances convertible to value_type.
libstdc++-v3/ChangeLog:
PR libstdc++/105717
* include/bits/hashtable_policy.h (_ConvertToValueType): New.
* include/bits/hashtable.h (_Hashtable<>::_M_insert_unique_aux):
New.
(_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&,
true_type)): Use latters.
(_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&,
false_type)): Likewise.
(_Hashtable(_InputIterator, _InputIterator, size_type, const
_Hash&, const _Equal&,
const allocator_type&, true_type)): Use this.insert range.
(_Hashtable(_InputIterator, _InputIterator, size_type, const
_Hash&, const _Equal&,
const allocator_type&, false_type)): Use _M_insert.
* testsuite/23_containers/unordered_map/cons/56112.cc: Check how
many times conversion
is done.
* testsuite/23_containers/unordered_map/insert/105717.cc: New test.
* testsuite/23_containers/unordered_set/insert/105717.cc: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-15 18:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 10:29 [Bug libstdc++/105717] New: [9/10/11/12/13 Regression] cannot create unordered_map from range of types convertible to value_type redi at gcc dot gnu.org
2022-05-24 10:30 ` [Bug libstdc++/105717] " redi at gcc dot gnu.org
2022-05-24 12:36 ` rguenth at gcc dot gnu.org
2022-06-15 18:30 ` [Bug libstdc++/105717] [10/11/12/13 " fdumont 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).