mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +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:
parent
55d338b66f
commit
e1b8a2e517
1 changed files with 7 additions and 1 deletions
|
@ -44,16 +44,22 @@ TEST_CASE(should_construct_by_move)
|
||||||
EXPECT_EQ(1, n->num_moves);
|
EXPECT_EQ(1, n->num_moves);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(should_not_destroy)
|
NO_SANITIZE_ADDRESS static void should_not_destroy()
|
||||||
{
|
{
|
||||||
Counter* c = nullptr;
|
Counter* c = nullptr;
|
||||||
{
|
{
|
||||||
AK::NeverDestroyed<Counter> n {};
|
AK::NeverDestroyed<Counter> n {};
|
||||||
|
// note: explicit stack-use-after-scope
|
||||||
c = &n.get();
|
c = &n.get();
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, c->num_destroys);
|
EXPECT_EQ(0, c->num_destroys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(should_not_destroy)
|
||||||
|
{
|
||||||
|
should_not_destroy();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE(should_provide_dereference_operator)
|
TEST_CASE(should_provide_dereference_operator)
|
||||||
{
|
{
|
||||||
AK::NeverDestroyed<Counter> n {};
|
AK::NeverDestroyed<Counter> n {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue