From aa65799c19d14c190e1834255a259fc4f579cbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 25 Dec 2013 19:56:00 +0100 Subject: [PATCH] pointerArithBool: Updated error message --- lib/checkbool.cpp | 3 ++- test/testbool.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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()); } };