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
{{ message }}
Repository navigation
Commit f4b877b
Browse filesBrowse the repository at this point in the historyBrowse files
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
@@ -6234,7 +6234,19 @@ class TestCondition : public TestFixture {
6234
6234
" if (ptr + 1 != 0);\n"
6235
6235
"}");
6236
6236
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());
6237
-
}
6237
+
6238
+
check("void f(char *ptr) {\n"
6239
+
" int *q = ptr + 1;\n"
6240
+
" if (q != 0);\n"
6241
+
"}");
6242
+
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());
6243
+
6244
+
check("void f(char *ptr) {\n"
6245
+
" int *q = ptr + 1;\n"
6246
+
" if (q);\n"
6247
+
"}");
6248
+
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