diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 02810906fb2..86b0f4aeeb9 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -145,6 +145,7 @@ class TestNullPointer : public TestFixture { TEST_CASE(nullpointer105); // #13861 TEST_CASE(nullpointer106); // #13682 TEST_CASE(nullpointer107); // #13682 (FP/FN cases around guards that depend on the pointer indirectly) + TEST_CASE(nullpointer108); TEST_CASE(nullpointer_addressOf); // address of TEST_CASE(nullpointerSwitch); // #2626 TEST_CASE(nullpointer_cast); // #4692 @@ -3105,6 +3106,15 @@ class TestNullPointer : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void nullpointer108() { // #14422 + check("void f() {\n" + " int *p{};\n" + " int *&r{p};\n" + " if (*r) {}\n" + "}"); + ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: r [nullPointer]\n", errout_str()); + } + void nullpointer_addressOf() { // address of check("void f() {\n" " struct X *x = 0;\n"