diff --git a/src/checkstl.cpp b/src/checkstl.cpp index 64d88eeb1..1a47dd8e5 100644 --- a/src/checkstl.cpp +++ b/src/checkstl.cpp @@ -399,7 +399,6 @@ void CheckStl::stlBoundries() else if (Token::Match(tok2, "%varid% <", iteratorid)) { stlBoundriesError(tok2, container_name); - break; } } } diff --git a/test/teststl.cpp b/test/teststl.cpp index 8429eeec6..694e5562e 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -59,6 +59,7 @@ private: TEST_CASE(invalidcode); TEST_CASE(stlBoundries1); + TEST_CASE(stlBoundries2); } void check(const char code[]) @@ -396,6 +397,20 @@ private: } } + void stlBoundries2() + { + const std::string checkStr("void f()\n" + "{\n" + " std::vector files;\n" + " std::vector::const_iterator it;\n" + " for (it = files.begin(); it < files.end(); it++) { }\n" + " for (it = files.begin(); it < files.end(); it++) { };\n" + "}\n"); + + check(checkStr.c_str()); + + ASSERT_EQUALS("[test.cpp:5]: (error) vector range check should use != and not < since the order of the pointers isn't guaranteed\n[test.cpp:6]: (error) vector range check should use != and not < since the order of the pointers isn't guaranteed\n", errout.str()); + } };