From 82e3a826871effc7093852a9181f641c693ae94f Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <jwakely@redhat.com>
Date: Thu, 7 Oct 2021 20:33:45 +0100
Subject: libstdc++: Restore debug checks in uniform container erasure
 functions

This partially reverts commit 561078480ffb5adb68577276c6b23e4ee7b39272.

If we avoid all debug mode checks when erasing elements then we fail to
invalidate safe iterators to the removed elements. This reverts the
recent changes in r12-4083 and r12-4233, restoring the debug checking.

libstdc++-v3/ChangeLog:

	* include/experimental/deque (erase, erase_if): Revert changes
	to avoid debug mode overhead.
	* include/experimental/map (erase, erase_if): Likewise.
	* include/experimental/set (erase, erase_if): Likewise.
	* include/experimental/unordered_map (erase, erase_if):
	Likewise.
	* include/experimental/unordered_set (erase, erase_if):
	Likewise.
	* include/experimental/vector (erase, erase_if): Likewise.
	* include/std/deque (erase, erase_if): Likewise.
	* include/std/map (erase, erase_if): Likewise.
	* include/std/set (erase, erase_if): Likewise.
	* include/std/unordered_map (erase, erase_if): Likewise.
	* include/std/unordered_set (erase, erase_if): Likewise.
	* include/std/vector (erase, erase_if): Likewise.
---
 libstdc++-v3/include/experimental/map | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

(limited to 'libstdc++-v3/include/experimental/map')

diff --git a/libstdc++-v3/include/experimental/map b/libstdc++-v3/include/experimental/map
index ef69fad..0c0f422 100644
--- a/libstdc++-v3/include/experimental/map
+++ b/libstdc++-v3/include/experimental/map
@@ -50,19 +50,13 @@ inline namespace fundamentals_v2
 	   typename _Predicate>
     inline void
     erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    {
-      _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>& __c = __cont;
-      std::__detail::__erase_nodes_if(__c, __pred);
-    }
+    { std::__detail::__erase_nodes_if(__cont, __pred); }
 
   template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
 	   typename _Predicate>
     inline void
     erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
-    {
-      _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>& __c = __cont;
-      std::__detail::__erase_nodes_if(__c, __pred);
-    }
+    { std::__detail::__erase_nodes_if(__cont, __pred); }
 
   namespace pmr {
     template<typename _Key, typename _Tp, typename _Compare = less<_Key>>
-- 
cgit v1.1