You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testcondition.cpp
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6248,7 +6248,19 @@ class TestCondition : public TestFixture {
6248
6248
" if (ptr + 1 != 0);\n"
6249
6249
"}");
6250
6250
ASSERT_EQUALS("[test.cpp:2:15]: (warning) Comparison is wrong. Result of 'ptr+1' can't be 0 unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
6251
-
}
6251
+
6252
+
check("void f(char *ptr) {\n"
6253
+
" int *q = ptr + 1;\n"
6254
+
" if (q != 0);\n"
6255
+
"}");
6256
+
ASSERT_EQUALS("[test.cpp:3:9]: (warning) Comparison is wrong. Result of 'q' can't be 0 unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
6257
+
6258
+
check("void f(char *ptr) {\n"
6259
+
" int *q = ptr + 1;\n"
6260
+
" if (q);\n"
6261
+
"}");
6262
+
ASSERT_EQUALS("[test.cpp:3:7]: (warning) Comparison is wrong. Result of 'q' can't be 0 unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
0 commit comments