diff options
author | Evan Brown <ezb@google.com> | 2023-10-16 11:57:00 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-16 11:57:40 -0700 |
commit | d368d3d64993b27f483a51de3d458b7cbdc2c544 (patch) | |
tree | 8b816874e6e9fb31c81c9c612ea689a41a1d4749 /absl/container/internal/raw_hash_set_test.cc | |
parent | 99bbd7c4865c5d0f3bfbe99457c5ce4daf6ba174 (diff) | |
download | abseil-d368d3d64993b27f483a51de3d458b7cbdc2c544.tar.gz abseil-d368d3d64993b27f483a51de3d458b7cbdc2c544.tar.bz2 abseil-d368d3d64993b27f483a51de3d458b7cbdc2c544.zip |
Add iterator invalidation checking for when the hashtable is moved.
Motivation: once we enable small object optimization in swisstable, iterators can be invalidated when the table is moved.
PiperOrigin-RevId: 573884505
Change-Id: I4278129829143d3747dfd0ef0ff92f321c2633dc
Diffstat (limited to 'absl/container/internal/raw_hash_set_test.cc')
-rw-r--r-- | absl/container/internal/raw_hash_set_test.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index 61eb6d95..d194ca1b 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -2370,6 +2370,19 @@ TEST(Iterator, InvalidUseWithReserveCrashesWithSanitizers) { #endif } +TEST(Iterator, InvalidUseWithMoveCrashesWithSanitizers) { + if (!SwisstableGenerationsEnabled()) GTEST_SKIP() << "Generations disabled."; + if (kMsvc) GTEST_SKIP() << "MSVC doesn't support | in regexp."; + + IntTable t1, t2; + t1.insert(1); + auto it = t1.begin(); + t2 = std::move(t1); + EXPECT_DEATH_IF_SUPPORTED(*it, kInvalidIteratorDeathMessage); + EXPECT_DEATH_IF_SUPPORTED(void(it == t2.begin()), + kInvalidIteratorDeathMessage); +} + TEST(Table, ReservedGrowthUpdatesWhenTableDoesntGrow) { IntTable t; for (int i = 0; i < 8; ++i) t.insert(i); |