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
@@ -6129,7 +6129,19 @@ class TestCondition : public TestFixture {
6129
6129
" if (ptr + 1 != 0);\n"
6130
6130
"}");
6131
6131
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());
6132
-
}
6132
+
6133
+
check("void f(char *ptr) {\n"
6134
+
" int *q = ptr + 1;\n"
6135
+
" if (q != 0);\n"
6136
+
"}");
6137
+
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());
6138
+
6139
+
check("void f(char *ptr) {\n"
6140
+
" int *q = ptr + 1;\n"
6141
+
" if (q);\n"
6142
+
"}");
6143
+
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