diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 3ecaf21e2..6884d3b67 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -551,5 +551,6 @@ void CheckBool::pointerArithBoolError(const Token *tok) reportError(tok, Severity::error, "pointerArithBool", - "Converting pointer arithmetic result to bool. Either a dereference is forgot, or pointer overflow is required to get a false value"); + "Converting pointer arithmetic result to bool. The bool is always true unless there is undefined behaviour.\n" + "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."); } diff --git a/test/testbool.cpp b/test/testbool.cpp index eca537fb6..6d96396c6 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -877,12 +877,12 @@ private: check("void f(char *p) {\n" " if (p+1){}\n" "}"); - 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()); + 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()); check("void f(char *p) {\n" " if (p && p+1){}\n" "}"); - 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()); + 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()); } };