Skip to content

Commit 8004db4

Browse files
Update testnullpointer.cpp
1 parent a5442c8 commit 8004db4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/testnullpointer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,14 @@ class TestNullPointer : public TestFixture {
24582458
" if (h(i) && *i == 1) {}\n"
24592459
"}\n");
24602460
ASSERT_EQUALS("", errout_str());
2461+
2462+
check("void f(int i) {\n" // #13797
2463+
" int* p = nullptr;\n"
2464+
" if (!i) {\n"
2465+
" *p = 0;\n"
2466+
" }\n"
2467+
"}\n");
2468+
ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: p [nullPointer]\n", errout_str());
24612469
}
24622470

24632471
void nullpointer78() // #7802
@@ -3929,7 +3937,9 @@ class TestNullPointer : public TestFixture {
39293937
" std::string s(p);\n"
39303938
" return s;\n"
39313939
"}\n", dinit(CheckOptions, $.inconclusive = true));
3932-
ASSERT_EQUALS("", errout_str());
3940+
TODO_ASSERT_EQUALS("",
3941+
"[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n",
3942+
errout_str());
39333943

39343944
check("void f() {\n" // #11078
39353945
" const char* p = nullptr;\n"

0 commit comments

Comments
 (0)