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
@@ -1869,6 +1873,12 @@ void CheckCondition::pointerAdditionResultNotNullError(const Token *tok, const T
1869
1873
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";
1879
+
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
@@ -6245,7 +6245,19 @@ class TestCondition : public TestFixture {
6245
6245
" int *q = ptr + 1;\n"
6246
6246
" if (q);\n"
6247
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());
6248
+
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());
6249
+
6250
+
check("void f(char *ptr) {\n"
6251
+
" int *q = ptr + 1;\n"
6252
+
" if (!q);\n"
6253
+
"}");
6254
+
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