Commit ba835d56 by Evan Brown Committed by Copybara-Service

Add more debug capacity validation checks on copies.

PiperOrigin-RevId: 675191249
Change-Id: I8fde03e0db6e014853730d63fa1924fd2290bf3e
parent f7c22f52
...@@ -2748,6 +2748,7 @@ class raw_hash_set { ...@@ -2748,6 +2748,7 @@ class raw_hash_set {
raw_hash_set(const raw_hash_set& that, const allocator_type& a) raw_hash_set(const raw_hash_set& that, const allocator_type& a)
: raw_hash_set(GrowthToLowerboundCapacity(that.size()), that.hash_ref(), : raw_hash_set(GrowthToLowerboundCapacity(that.size()), that.hash_ref(),
that.eq_ref(), a) { that.eq_ref(), a) {
that.AssertNotDebugCapacity();
const size_t size = that.size(); const size_t size = that.size();
if (size == 0) { if (size == 0) {
return; return;
...@@ -2843,6 +2844,7 @@ class raw_hash_set { ...@@ -2843,6 +2844,7 @@ class raw_hash_set {
} }
raw_hash_set& operator=(const raw_hash_set& that) { raw_hash_set& operator=(const raw_hash_set& that) {
that.AssertNotDebugCapacity();
if (ABSL_PREDICT_FALSE(this == &that)) return *this; if (ABSL_PREDICT_FALSE(this == &that)) return *this;
constexpr bool propagate_alloc = constexpr bool propagate_alloc =
AllocTraits::propagate_on_container_copy_assignment::value; AllocTraits::propagate_on_container_copy_assignment::value;
......
...@@ -3694,6 +3694,8 @@ TEST(Table, MovedFromCallsFail) { ...@@ -3694,6 +3694,8 @@ TEST(Table, MovedFromCallsFail) {
EXPECT_DEATH_IF_SUPPORTED(t1.swap(t3), "moved-from"); EXPECT_DEATH_IF_SUPPORTED(t1.swap(t3), "moved-from");
// NOLINTNEXTLINE(bugprone-use-after-move) // NOLINTNEXTLINE(bugprone-use-after-move)
EXPECT_DEATH_IF_SUPPORTED(t1.merge(t3), "moved-from"); EXPECT_DEATH_IF_SUPPORTED(t1.merge(t3), "moved-from");
// NOLINTNEXTLINE(bugprone-use-after-move)
EXPECT_DEATH_IF_SUPPORTED(IntTable{t1}, "moved-from");
} }
{ {
ABSL_ATTRIBUTE_UNUSED IntTable t1; ABSL_ATTRIBUTE_UNUSED IntTable t1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment