Improve message for container type range check.
See thread: https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192&start=0
This commit is contained in:
parent
ad89a84796
commit
f5f2a2ce2a
|
@ -662,11 +662,13 @@ void CheckStl::stlBoundries()
|
||||||
// Error message for bad boundry usage..
|
// Error message for bad boundry usage..
|
||||||
void CheckStl::stlBoundriesError(const Token *tok, const std::string &container_name)
|
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()
|
void CheckStl::if_find()
|
||||||
{
|
{
|
||||||
if (!_settings->_checkCodingStyle)
|
if (!_settings->_checkCodingStyle)
|
||||||
|
|
|
@ -924,7 +924,7 @@ private:
|
||||||
" ;\n"
|
" ;\n"
|
||||||
"}\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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue