1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +00:00

Tests: Mark use-after-scope NeverDestroyed test NO_SANITIZE_ADDRESS

The should_not_destroy test case intentionally performs an invalid stack
access on a NeverDestroyed to confirm that the destructor for the held
type was not called.
This commit is contained in:
Andrew Kaster 2021-05-12 05:51:59 -06:00 committed by Linus Groh
parent 55d338b66f
commit e1b8a2e517

View file

@ -44,16 +44,22 @@ TEST_CASE(should_construct_by_move)
EXPECT_EQ(1, n->num_moves);
}
TEST_CASE(should_not_destroy)
NO_SANITIZE_ADDRESS static void should_not_destroy()
{
Counter* c = nullptr;
{
AK::NeverDestroyed<Counter> n {};
// note: explicit stack-use-after-scope
c = &n.get();
}
EXPECT_EQ(0, c->num_destroys);
}
TEST_CASE(should_not_destroy)
{
should_not_destroy();
}
TEST_CASE(should_provide_dereference_operator)
{
AK::NeverDestroyed<Counter> n {};