diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b69c74fa7..e475adf8c 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2666,7 +2666,10 @@ void CheckOther::selfAssignmentError(const Token *tok, const std::string &varnam void CheckOther::assignmentInAssertError(const Token *tok, const std::string &varname) { reportError(tok, Severity::warning, - "assignmentInAssert", "Assert statement modifies '" + varname + "'. If the modification is needed in release builds there is a bug."); + "assignmentInAssert", "Assert statement modifies '" + varname + "'.\n" + "Assert statements are removed from release builds so the code inside " + "assert statement is not run. If the code is needed also in release " + "builds this is a bug."); } void CheckOther::incorrectLogicOperatorError(const Token *tok) diff --git a/test/testother.cpp b/test/testother.cpp index 74087c9f9..5691aedd1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1336,7 +1336,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str()); check("void f() {\n" " int a = 0;\n" @@ -1353,7 +1353,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:4]: (warning) Assert statement modifies 'b'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning) Assert statement modifies 'b'.\n", errout.str()); check("void f() {\n" " int a = 0;\n" @@ -1361,7 +1361,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str()); check("void f() {\n" " int a = 0;\n" @@ -1369,7 +1369,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str()); check("void f() {\n" " int a = 0;\n" @@ -1377,7 +1377,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str()); check("void f() {\n" " int a = 0;\n" @@ -1385,7 +1385,7 @@ private: " return a;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'. If the modification is needed in release builds there is a bug.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) Assert statement modifies 'a'.\n", errout.str()); } void incorrectLogicOperator()