Skip to content

Commit 678290c

Browse files
Add test for #14422 (#8742)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 2807561 commit 678290c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/testnullpointer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class TestNullPointer : public TestFixture {
145145
TEST_CASE(nullpointer105); // #13861
146146
TEST_CASE(nullpointer106); // #13682
147147
TEST_CASE(nullpointer107); // #13682 (FP/FN cases around guards that depend on the pointer indirectly)
148+
TEST_CASE(nullpointer108);
148149
TEST_CASE(nullpointer_addressOf); // address of
149150
TEST_CASE(nullpointerSwitch); // #2626
150151
TEST_CASE(nullpointer_cast); // #4692
@@ -3105,6 +3106,15 @@ class TestNullPointer : public TestFixture {
31053106
ASSERT_EQUALS("", errout_str());
31063107
}
31073108

3109+
void nullpointer108() { // #14422
3110+
check("void f() {\n"
3111+
" int *p{};\n"
3112+
" int *&r{p};\n"
3113+
" if (*r) {}\n"
3114+
"}");
3115+
ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: r [nullPointer]\n", errout_str());
3116+
}
3117+
31083118
void nullpointer_addressOf() { // address of
31093119
check("void f() {\n"
31103120
" struct X *x = 0;\n"

0 commit comments

Comments
 (0)