* Fix Debug DR2354
@ 2017-12-19 21:33 François Dumont
2017-12-24 7:55 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: François Dumont @ 2017-12-19 21:33 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
Hi
 I plan to apply attached patch tomorrow to fix those _GLIBCXX_DEBUG
failures:
FAIL: 23_containers/map/modifiers/insert/dr2354.cc (test for excess errors)
FAIL: 23_containers/multimap/modifiers/insert/dr2354.cc (test for excess errors)
FAIL: 23_containers/unordered_map/insert/dr2354.cc (test for excess errors)
FAIL: 23_containers/unordered_multimap/insert/dr2354.cc (test for excess errors)
I am also adding tests checking additional DR 2354 insert overloads. I discovered I needed to add those only because I looked at the ChangeLog entry.
 Tested under Linux x86_64 Debug mode.
François
[-- Attachment #2: debug_dr2354.patch --]
[-- Type: text/x-patch, Size: 8305 bytes --]
diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h
index 4844a62..4a31f41 100644
--- a/libstdc++-v3/include/debug/map.h
+++ b/libstdc++-v3/include/debug/map.h
@@ -260,6 +260,15 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ std::pair<iterator, bool>
+ insert(value_type&& __x)
+ {
+ auto __res = _Base::insert(std::move(__x));
+ return { iterator(__res.first, this), __res.second };
+ }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
@@ -291,6 +300,15 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(const_iterator __position, value_type&& __x)
+ {
+ __glibcxx_check_insert(__position);
+ return { _Base::insert(__position.base(), std::move(__x)), this };
+ }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h
index b6862ab..c01d039 100644
--- a/libstdc++-v3/include/debug/multimap.h
+++ b/libstdc++-v3/include/debug/multimap.h
@@ -244,6 +244,12 @@ namespace __debug
{ return iterator(_Base::insert(__x), this); }
#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(value_type&& __x)
+ { return { _Base::insert(std::move(__x)), this }; }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
@@ -270,6 +276,15 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(const_iterator __position, value_type&& __x)
+ {
+ __glibcxx_check_insert(__position);
+ return { _Base::insert(__position.base(), std::move(__x)), this };
+ }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map
index 0ed9922..6757339 100644
--- a/libstdc++-v3/include/debug/unordered_map
+++ b/libstdc++-v3/include/debug/unordered_map
@@ -312,19 +312,20 @@ namespace __debug
insert(const value_type& __obj)
{
size_type __bucket_count = this->bucket_count();
- std::pair<_Base_iterator, bool> __res = _Base::insert(__obj);
+ auto __res = _Base::insert(__obj);
_M_check_rehashed(__bucket_count);
- return std::make_pair(iterator(__res.first, this), __res.second);
+ return { iterator(__res.first, this), __res.second };
}
- iterator
- insert(const_iterator __hint, const value_type& __obj)
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ std::pair<iterator, bool>
+ insert(value_type&& __x)
{
- __glibcxx_check_insert(__hint);
size_type __bucket_count = this->bucket_count();
- _Base_iterator __it = _Base::insert(__hint.base(), __obj);
+ auto __res = _Base::insert(std::move(__x));
_M_check_rehashed(__bucket_count);
- return iterator(__it, this);
+ return { iterator(__res.first, this), __res.second };
}
template<typename _Pair, typename = typename
@@ -340,6 +341,28 @@ namespace __debug
return std::make_pair(iterator(__res.first, this), __res.second);
}
+ iterator
+ insert(const_iterator __hint, const value_type& __obj)
+ {
+ __glibcxx_check_insert(__hint);
+ size_type __bucket_count = this->bucket_count();
+ _Base_iterator __it = _Base::insert(__hint.base(), __obj);
+ _M_check_rehashed(__bucket_count);
+ return iterator(__it, this);
+ }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(const_iterator __hint, value_type&& __x)
+ {
+ __glibcxx_check_insert(__hint);
+ size_type __bucket_count = this->bucket_count();
+ auto __it = _Base::insert(__hint.base(), std::move(__x));
+ _M_check_rehashed(__bucket_count);
+ return iterator(__it, this);
+ }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
@@ -977,6 +1000,17 @@ namespace __debug
return iterator(__it, this);
}
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(value_type&& __x)
+ {
+ size_type __bucket_count = this->bucket_count();
+ auto __it = _Base::insert(std::move(__x));
+ _M_check_rehashed(__bucket_count);
+ return { __it, this };
+ }
+
iterator
insert(const_iterator __hint, const value_type& __obj)
{
@@ -987,6 +1021,18 @@ namespace __debug
return iterator(__it, this);
}
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2354. Unnecessary copying when inserting into maps with braced-init
+ iterator
+ insert(const_iterator __hint, value_type&& __x)
+ {
+ __glibcxx_check_insert(__hint);
+ size_type __bucket_count = this->bucket_count();
+ auto __it = _Base::insert(__hint.base(), std::move(__x));
+ _M_check_rehashed(__bucket_count);
+ return iterator(__it, this);
+ }
+
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/dr2354.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/dr2354.cc
index 338d9fd..cc0fcbb 100644
--- a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/dr2354.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/dr2354.cc
@@ -30,3 +30,10 @@ test01()
std::map<int, MoveOnly> m;
m.insert({1, 2}); // PR libstdc++/82522 - LWG 2354
}
+
+void
+test02()
+{
+ std::map<int, MoveOnly> m;
+ m.insert(m.begin(), {1, 2}); // PR libstdc++/82522 - LWG 2354
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/dr2354.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/dr2354.cc
index ca743ec..73cbf4c 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/dr2354.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/dr2354.cc
@@ -30,3 +30,10 @@ test01()
std::multimap<int, MoveOnly> m;
m.insert({1, 2}); // PR libstdc++/82522 - LWG 2354
}
+
+void
+test02()
+{
+ std::multimap<int, MoveOnly> m;
+ m.insert(m.begin(), {1, 2}); // PR libstdc++/82522 - LWG 2354
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/insert/dr2354.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/insert/dr2354.cc
index fe53565..3507efa 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/insert/dr2354.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/insert/dr2354.cc
@@ -30,3 +30,10 @@ test01()
std::unordered_map<int, MoveOnly> m;
m.insert({1, 2}); // PR libstdc++/82522 - LWG 2354
}
+
+void
+test02()
+{
+ std::unordered_map<int, MoveOnly> m;
+ m.insert(m.begin(), {1, 2}); // PR libstdc++/82522 - LWG 2354
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/dr2354.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/dr2354.cc
index 5a27242..ff66113 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/dr2354.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/insert/dr2354.cc
@@ -30,3 +30,10 @@ test01()
std::unordered_multimap<int, MoveOnly> m;
m.insert({1, 2}); // PR libstdc++/82522 - LWG 2354
}
+
+void
+test02()
+{
+ std::unordered_multimap<int, MoveOnly> m;
+ m.insert(m.begin(), {1, 2}); // PR libstdc++/82522 - LWG 2354
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix Debug DR2354
2017-12-19 21:33 Fix Debug DR2354 François Dumont
@ 2017-12-24 7:55 ` Jonathan Wakely
2017-12-28 5:38 ` François Dumont
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2017-12-24 7:55 UTC (permalink / raw)
To: François Dumont; +Cc: libstdc++, gcc-patches
On 19 December 2017 at 21:33, François Dumont wrote:
> Hi
>
> I plan to apply attached patch tomorrow to fix those _GLIBCXX_DEBUG
> failures:
>
> FAIL: 23_containers/map/modifiers/insert/dr2354.cc (test for excess errors)
> FAIL: 23_containers/multimap/modifiers/insert/dr2354.cc (test for excess
> errors)
> FAIL: 23_containers/unordered_map/insert/dr2354.cc (test for excess errors)
> FAIL: 23_containers/unordered_multimap/insert/dr2354.cc (test for excess
> errors)
>
> I am also adding tests checking additional DR 2354 insert overloads. I
> discovered I needed to add those only because I looked at the ChangeLog
> entry.
>
> Tested under Linux x86_64 Debug mode.
Thanks, this also needs to be fixed on gcc-7-branch.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix Debug DR2354
2017-12-24 7:55 ` Jonathan Wakely
@ 2017-12-28 5:38 ` François Dumont
0 siblings, 0 replies; 3+ messages in thread
From: François Dumont @ 2017-12-28 5:38 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc-patches
Now backported to branch.
On 24/12/2017 08:55, Jonathan Wakely wrote:
> On 19 December 2017 at 21:33, François Dumont wrote:
>> Hi
>>
>> I plan to apply attached patch tomorrow to fix those _GLIBCXX_DEBUG
>> failures:
>>
>> FAIL: 23_containers/map/modifiers/insert/dr2354.cc (test for excess errors)
>> FAIL: 23_containers/multimap/modifiers/insert/dr2354.cc (test for excess
>> errors)
>> FAIL: 23_containers/unordered_map/insert/dr2354.cc (test for excess errors)
>> FAIL: 23_containers/unordered_multimap/insert/dr2354.cc (test for excess
>> errors)
>>
>> I am also adding tests checking additional DR 2354 insert overloads. I
>> discovered I needed to add those only because I looked at the ChangeLog
>> entry.
>>
>> Tested under Linux x86_64 Debug mode.
> Thanks, this also needs to be fixed on gcc-7-branch.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-28 5:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 21:33 Fix Debug DR2354 François Dumont
2017-12-24 7:55 ` Jonathan Wakely
2017-12-28 5:38 ` François Dumont
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).