diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 74354bcc4..a0a4fb39b 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1340,7 +1340,7 @@ void CheckStl::uselessCalls() uselessCallsSubstrError(tok, true); } else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style) uselessCallsEmptyError(tok->next()); - else if (Token::Match(tok, "[{};] std :: remove (")) + else if (Token::Match(tok, "[{};] std :: remove (") && tok->tokAt(5)->nextArgument()) uselessCallsRemoveError(tok->next()); } } diff --git a/test/teststl.cpp b/test/teststl.cpp index ca69de985..c1eaf328f 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1941,6 +1941,7 @@ private: " std::remove(a.begin(), a.end(), val);\n" " x = std::remove(a.begin(), a.end(), val);\n" " a.erase(std::remove(a.begin(), a.end(), val));\n" + " std::remove(\"foo.txt\");\n" "}\n"); ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n", errout.str()); }