summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Copybara-Service <copybara-worker@google.com>2023-06-12 13:37:01 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-06-12 13:37:01 -0700
commit0af0103d3454d312b19d928255996a192df45ec7 (patch)
treea214189e79da3bff0f67dded943d5f06f40eb0de
parent5d1f1cf9dd9455b9ff41fa3e6009f9c40feaf2f2 (diff)
parentfc7467b0182914102a97f6dd7e83ae1f8927eb2a (diff)
Merge pull request #1475 from anpol:placement-new-array-needs-more-space
PiperOrigin-RevId: 539747818 Change-Id: Ia0ab0fdda0ffe9b23d83d55c899f301df20b1179
-rw-r--r--absl/base/exception_safety_testing_test.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/absl/base/exception_safety_testing_test.cc b/absl/base/exception_safety_testing_test.cc
index a87fd6a9..bf5aa7cf 100644
--- a/absl/base/exception_safety_testing_test.cc
+++ b/absl/base/exception_safety_testing_test.cc
@@ -148,7 +148,7 @@ TEST(ThrowingValueTest, ThrowingBitwiseOps) {
ThrowingValue<> bomb1, bomb2;
TestOp([&bomb1]() { ~bomb1; });
- TestOp([&]() { bomb1& bomb2; });
+ TestOp([&]() { bomb1 & bomb2; });
TestOp([&]() { bomb1 | bomb2; });
TestOp([&]() { bomb1 ^ bomb2; });
}
@@ -332,13 +332,16 @@ TEST(ThrowingValueTest, NonThrowingPlacementDelete) {
constexpr int kArrayLen = 2;
// We intentionally create extra space to store the tag allocated by placement
// new[].
- constexpr int kStorageLen = 4;
+ constexpr size_t kExtraSpaceLen = sizeof(size_t) * 2;
alignas(ThrowingValue<>) unsigned char buf[sizeof(ThrowingValue<>)];
alignas(ThrowingValue<>) unsigned char
- array_buf[sizeof(ThrowingValue<>[kStorageLen])];
+ array_buf[kExtraSpaceLen + sizeof(ThrowingValue<>[kArrayLen])];
auto* placed = new (&buf) ThrowingValue<>(1);
auto placed_array = new (&array_buf) ThrowingValue<>[kArrayLen];
+ auto* placed_array_end = reinterpret_cast<unsigned char*>(placed_array) +
+ sizeof(ThrowingValue<>[kArrayLen]);
+ EXPECT_LE(placed_array_end, array_buf + sizeof(array_buf));
SetCountdown();
ExpectNoThrow([placed, &buf]() {