[libcxx-commits] [libcxx] 9ea2db2 - [libc++] [LIBCXX-DEBUG-FIXME] Stop using invalid iterators to insert into sets/maps.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 5 13:23:50 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-05-05T16:21:09-04:00
New Revision: 9ea2db2c513534aa63acc087b8dc744c37119d02
URL: https://github.com/llvm/llvm-project/commit/9ea2db2c513534aa63acc087b8dc744c37119d02
DIFF: https://github.com/llvm/llvm-project/commit/9ea2db2c513534aa63acc087b8dc744c37119d02.diff
LOG: [libc++] [LIBCXX-DEBUG-FIXME] Stop using invalid iterators to insert into sets/maps.
This simply applies Howard's commit 4c80bfbd53caf consistently
across all the associative and unordered container tests.
"unord.set/insert_hint_const_lvalue.pass.cpp" failed with `-D_LIBCPP_DEBUG=1`
before this patch; it was the only one that incorrectly reused
invalid iterator `e`. The others already used valid iterators
(generally `c.end()`); I'm just making them all match the same pattern
of usage: "e, then r, then c.end() for the rest."
Differential Revision: https://reviews.llvm.org/D101679
Added:
Modified:
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
index cf18daf767be2..208d4827d72e3 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -35,7 +35,7 @@ void do_insert_hint_const_lvalue_test()
assert(r->second == 3);
const VT v2(3.5, 4);
- r = c.insert(c.end(), v2);
+ r = c.insert(r, v2);
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
index 48293d065d227..44ed22791ffbb 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -38,7 +38,7 @@ int main(int, char**)
assert(r->first == 3.5);
assert(r->second == 3);
- r = c.insert(c.end(), P(3.5, static_cast<short>(4)));
+ r = c.insert(r, P(3.5, static_cast<short>(4)));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
@@ -64,7 +64,7 @@ int main(int, char**)
assert(r->first == 3);
assert(r->second == 3);
- r = c.insert(c.end(), P(3, 4));
+ r = c.insert(r, P(3, 4));
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == 3);
@@ -91,7 +91,7 @@ int main(int, char**)
assert(r->first == 3.5);
assert(r->second == 3);
- r = c.insert(c.end(), P(3.5, static_cast<short>(4)));
+ r = c.insert(r, P(3.5, static_cast<short>(4)));
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
@@ -118,7 +118,7 @@ int main(int, char**)
assert(r->first == 3);
assert(r->second == 3);
- r = c.insert(c.end(), P(3, 4));
+ r = c.insert(r, P(3, 4));
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == 3);
@@ -143,7 +143,7 @@ int main(int, char**)
assert(r->first == 3.5);
assert(r->second == 3);
- r = c.insert(c.end(), {3.5, 4});
+ r = c.insert(r, {3.5, 4});
assert(c.size() == 1);
assert(r->first == 3.5);
assert(r->second == 3);
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
index cb79ddff41f78..b3a5487c07860 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -35,7 +35,7 @@ void do_insert_const_lvalue_test()
assert(r->second == 3);
const VT v2(3.5, 4);
- r = c.insert(c.end(), v2);
+ r = c.insert(r, v2);
assert(c.size() == 2);
assert(r->first == 3.5);
assert(r->second == 4);
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
index 461428e56eb0c..a33cada53684c 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
@@ -33,7 +33,7 @@ void do_insert_hint_const_lvalue_test()
assert(c.size() == 1);
assert(*r == 3.5);
- r = c.insert(c.end(), v1);
+ r = c.insert(r, v1);
assert(c.size() == 2);
assert(*r == 3.5);
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
index f0cf2b976df8b..16a9766e5f6e0 100644
--- a/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: LIBCXX-DEBUG-FIXME
-
// <unordered_set>
// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
@@ -35,17 +33,17 @@ void do_insert_hint_const_lvalue_test()
assert(c.size() == 1);
assert(*r == 3.5);
- r = c.insert(e, v1);
+ r = c.insert(r, v1);
assert(c.size() == 1);
assert(*r == 3.5);
const VT v2(4.5);
- r = c.insert(e, v2);
+ r = c.insert(c.end(), v2);
assert(c.size() == 2);
assert(*r == 4.5);
const VT v3(5.5);
- r = c.insert(e, v3);
+ r = c.insert(c.end(), v3);
assert(c.size() == 3);
assert(*r == 5.5);
}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
index 1ec66eead20e1..de67a912dc92c 100644
--- a/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
@@ -28,7 +28,8 @@ int main(int, char**)
typedef C::iterator R;
typedef double P;
C c;
- R r = c.insert(c.end(), P(3.5));
+ typename C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
assert(c.size() == 1);
assert(*r == 3.5);
@@ -50,7 +51,8 @@ int main(int, char**)
typedef C::iterator R;
typedef MoveOnly P;
C c;
- R r = c.insert(c.end(), P(3));
+ typename C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
assert(c.size() == 1);
assert(*r == 3);
@@ -72,7 +74,8 @@ int main(int, char**)
typedef C::iterator R;
typedef double P;
C c;
- R r = c.insert(c.end(), P(3.5));
+ typename C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
assert(c.size() == 1);
assert(*r == 3.5);
@@ -94,7 +97,8 @@ int main(int, char**)
typedef C::iterator R;
typedef MoveOnly P;
C c;
- R r = c.insert(c.end(), P(3));
+ typename C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
assert(c.size() == 1);
assert(*r == 3);
More information about the libcxx-commits
mailing list