diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 03ec5b09dfc..c9d1a3f804a 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -3213,6 +3213,8 @@ class raw_hash_set { // If the element already exists in `this`, it is left unmodified in `src`. template void merge(raw_hash_set& src) { // NOLINT + AssertNotDebugCapacity(); + src.AssertNotDebugCapacity(); assert(this != &src); // Returns whether insertion took place. const auto insert_slot = [this](slot_type* src_slot) { @@ -3263,6 +3265,8 @@ class raw_hash_set { IsNoThrowSwappable() && IsNoThrowSwappable() && IsNoThrowSwappable( typename AllocTraits::propagate_on_container_swap{})) { + AssertNotDebugCapacity(); + that.AssertNotDebugCapacity(); using std::swap; swap_common(that); swap(hash_ref(), that.hash_ref()); diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index 79c00fdc2de..307dc74881e 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -3685,11 +3685,15 @@ TEST(Table, MovedFromCallsFail) { } { - ABSL_ATTRIBUTE_UNUSED IntTable t1, t2; + ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3; t1.insert(1); t2 = std::move(t1); // NOLINTNEXTLINE(bugprone-use-after-move) EXPECT_DEATH_IF_SUPPORTED(t1.contains(1), "moved-from"); + // NOLINTNEXTLINE(bugprone-use-after-move) + EXPECT_DEATH_IF_SUPPORTED(t1.swap(t3), "moved-from"); + // NOLINTNEXTLINE(bugprone-use-after-move) + EXPECT_DEATH_IF_SUPPORTED(t1.merge(t3), "moved-from"); } { ABSL_ATTRIBUTE_UNUSED IntTable t1;