diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index c2f1fa15e..08ecd90d3 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -662,11 +662,13 @@ void CheckStl::stlBoundries() // Error message for bad boundry usage.. void CheckStl::stlBoundriesError(const Token *tok, const std::string &container_name) { - reportError(tok, Severity::error, "stlBoundries", container_name + " range check should use != and not < since the order of the pointers isn't guaranteed"); + reportError(tok, Severity::error, "stlBoundries", + "Dangerous container iterator compare using < operator for " + container_name + "\n" + "Using < operator with container type iterators is dangerous since the order of " + "the items is not guaranteed. One should use != operator instead when comparing " + "iterators in the container."); } - - void CheckStl::if_find() { if (!_settings->_checkCodingStyle) diff --git a/test/teststl.cpp b/test/teststl.cpp index 419c4bb76..4071bef6e 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -924,7 +924,7 @@ private: " ;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (error) " + stlCont[i] + " range check should use != and not < since the order of the pointers isn't guaranteed\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error) Dangerous container iterator compare using < operator for " + stlCont[i] + "\n", errout.str()); } }