Skip to content

Commit aa65799

Browse files
committed
pointerArithBool: Updated error message
1 parent 6182394 commit aa65799

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/checkbool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,5 +551,6 @@ void CheckBool::pointerArithBoolError(const Token *tok)
551551
reportError(tok,
552552
Severity::error,
553553
"pointerArithBool",
554-
"Converting pointer arithmetic result to bool. Either a dereference is forgot, or pointer overflow is required to get a false value");
554+
"Converting pointer arithmetic result to bool. The bool is always true unless there is undefined behaviour.\n"
555+
"Converting pointer arithmetic result to bool. The boolean result is always true unless there is pointer arithmetic overflow, and overflow is undefined behaviour. Probably a dereference is forgotten.");
555556
}

test/testbool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,12 +877,12 @@ class TestBool : public TestFixture {
877877
check("void f(char *p) {\n"
878878
" if (p+1){}\n"
879879
"}");
880-
ASSERT_EQUALS("[test.cpp:2]: (error) Converting pointer arithmetic result to bool. Either a dereference is forgot, or pointer overflow is required to get a false value\n", errout.str());
880+
ASSERT_EQUALS("[test.cpp:2]: (error) Converting pointer arithmetic result to bool. The bool is always true unless there is undefined behaviour.\n", errout.str());
881881

882882
check("void f(char *p) {\n"
883883
" if (p && p+1){}\n"
884884
"}");
885-
ASSERT_EQUALS("[test.cpp:2]: (error) Converting pointer arithmetic result to bool. Either a dereference is forgot, or pointer overflow is required to get a false value\n", errout.str());
885+
ASSERT_EQUALS("[test.cpp:2]: (error) Converting pointer arithmetic result to bool. The bool is always true unless there is undefined behaviour.\n", errout.str());
886886
}
887887
};
888888

0 commit comments

Comments
 (0)