diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6d9c6002e..d5fa4d410 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2878,6 +2878,12 @@ void CheckOther::checkComparisonOfBoolExpressionWithInt() const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase(); for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { + // Skip template parameters + if (tok->str() == "<" && tok->link()) { + tok = tok->link(); + continue; + } + const Token* numTok = 0; const Token* opTok = 0; char op = 0; diff --git a/test/testother.cpp b/test/testother.cpp index 733b8622f..f0ac608d7 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -124,6 +124,7 @@ private: TEST_CASE(comparisonOfBoolExpressionWithInt1); TEST_CASE(comparisonOfBoolExpressionWithInt2); + TEST_CASE(comparisonOfBoolExpressionWithInt3); TEST_CASE(incorrectStringCompare); @@ -3041,6 +3042,12 @@ private: ASSERT_EQUALS("", errout.str()); } + void comparisonOfBoolExpressionWithInt3() { + check("int f(int x) {\n" + " return t<0>() && x;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } void memsetZeroBytes() { check("void f() {\n"