Skip to content

Commit

Permalink
[slice] Ensure result is used in test (#31083)
Browse files Browse the repository at this point in the history
Otherwise sufficiently good compilers may inline SumSlice, see that the result is not used, and discard the code that triggers the crash entirely.
  • Loading branch information
ctiller committed Sep 22, 2022
1 parent 52f21ad commit 6575ae7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/core/slice/slice_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ TEST(SliceTest, ExternalAsOwned) {
// In ASAN (where we can be sure that it'll crash), go ahead and read the
// bytes we just deleted.
if (BuiltUnderAsan()) {
ASSERT_DEATH({ SumSlice(slice); }, "");
ASSERT_DEATH({ gpr_log(GPR_DEBUG, "%" PRIdPTR, SumSlice(slice)); }, "");
}
EXPECT_EQ(initial_sum, SumSlice(owned));
}
Expand Down

0 comments on commit 6575ae7

Please sign in to comment.