mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +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
Notes:
sideshowbarker
2024-07-18 18:11:15 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/e1b8a2e517a Pull-request: https://github.com/SerenityOS/serenity/pull/7060 Issue: https://github.com/SerenityOS/serenity/issues/4592
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);
|
||||
}
|
||||
|
||||
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 {};
|
||||
|
|
Loading…
Reference in a new issue