Skip to content

Commit

Permalink
Test that using a table that was moved-to from a moved-from table fai…
Browse files Browse the repository at this point in the history
…ls in sanitizer mode.

We previously added (and then rolled back) validation that caused moving a moved-from table to fail, but since we already validate the use-after-moved-to-from-moved-from case, it seems unnecessary to validate that we never move a moved-from table. Therefore, I don't think we need to pursue rolling forward the validation on moving a moved-from table.

PiperOrigin-RevId: 710749538
Change-Id: I64bbf7fd22fa160b47ad94fb8d51186e2a5bad3c
  • Loading branch information
ezbr authored and copybara-github committed Dec 30, 2024
1 parent fcc8630 commit f28f81c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions absl/container/internal/raw_hash_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3724,6 +3724,16 @@ TEST(Table, MovedFromCallsFail) {
EXPECT_DEATH_IF_SUPPORTED(t1.contains(1), "moved-from");
t1.clear(); // Clearing a moved-from table is allowed.
}
{
// Test that using a table (t3) that was moved-to from a moved-from table
// (t1) fails.
ABSL_ATTRIBUTE_UNUSED IntTable t1, t2, t3;
t1.insert(1);
t2 = std::move(t1);
// NOLINTNEXTLINE(bugprone-use-after-move)
t3 = std::move(t1);
EXPECT_DEATH_IF_SUPPORTED(t3.contains(1), "moved-from");
}
}

} // namespace
Expand Down

0 comments on commit f28f81c

Please sign in to comment.