[slice] Ensure result is used in test (#31083)

Otherwise sufficiently good compilers may inline SumSlice, see that the result is not used, and discard the code that triggers the crash entirely.
pull/31099/head
Craig Tiller 2 years ago committed by GitHub
parent 52f21adb01
commit 6575ae70b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      test/core/slice/slice_test.cc

@ -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));
}

Loading…
Cancel
Save