diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b07c4ace5..43829c89b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1741,7 +1741,7 @@ void CheckOther::checkConstantFunctionParameter() // const stream parameter). if (Token::Match(tok, "std :: string|wstring")) { passedByValueError(tok, var->name()); - } else if (Token::Match(tok, "std :: %type% <")) { + } else if (Token::Match(tok, "std :: %type% <") && !Token::Match(tok->linkAt(3), "> ::")) { passedByValueError(tok, var->name()); } else if (var->type() || symbolDatabase->isClassOrStruct(tok->str())) { // Check if type is a struct or class. passedByValueError(tok, var->name()); diff --git a/test/testother.cpp b/test/testother.cpp index 0ae96fbc7..41a217139 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -969,6 +969,9 @@ private: testPassedByValue("void f(const std::vector v) {}"); ASSERT_EQUALS("[test.cpp:1]: (performance) Function parameter 'v' should be passed by reference.\n", errout.str()); + testPassedByValue("void f(const std::vector::size_type s) {}"); + ASSERT_EQUALS("", errout.str()); + testPassedByValue("void f(const std::vector &v) {}"); ASSERT_EQUALS("", errout.str());