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
@@ -1874,6 +1878,12 @@ void CheckConditionImpl::pointerAdditionResultNotNullError(const Token *tok, con
1874
1878
reportError(tok, Severity::warning, "pointerAdditionResultNotNull", "Comparison is wrong. Result of '" + s + "' can't be 0 unless there is pointer overflow, and pointer overflow is undefined behaviour.");
const std::string s = calc ? calc->expressionString() : "ptr+1";
1884
+
reportError(tok, Severity::warning, "pointerAdditionResultNotNull", "Pointer expression '" + s + "' is always true unless there is pointer overflow, and pointer overflow is undefined behaviour.");
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
@@ -6259,7 +6259,19 @@ class TestCondition : public TestFixture {
6259
6259
" int *q = ptr + 1;\n"
6260
6260
" if (q);\n"
6261
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());
6262
+
ASSERT_EQUALS("[test.cpp:3:7]: (warning) Pointer expression 'q' is always true unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
6263
+
6264
+
check("void f(char *ptr) {\n"
6265
+
" int *q = ptr + 1;\n"
6266
+
" if (!q);\n"
6267
+
"}");
6268
+
ASSERT_EQUALS("[test.cpp:3:8]: (warning) Pointer expression 'q' is always true unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
0 commit comments