pointerArithBool: Updated error message

This commit is contained in:
Daniel Marjamäki 2013-12-25 19:56:00 +01:00
parent 6182394966
commit aa65799c19
2 changed files with 4 additions and 3 deletions

View File

@ -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.");
}

View File

@ -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());
}
};