diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index f4aed747de9..a8a4281b58b 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -741,7 +741,7 @@ void CheckCondition::multiCondition2() // Condition.. const Token *cond2 = tok->str() == "if" ? condStartToken->astOperand2() : condStartToken->astOperand1(); - const bool isReturnVar = (tok->str() == "return" && (!Token::Match(cond2, "%cop%") || (cond2 && cond2->isUnaryOp("!")))); + const bool isReturnVar = (tok->str() == "return" && (!Token::Match(cond2, "%cop%") || cond2->isUnaryOp("!") || cond2->isUnaryOp("*"))); ErrorPath errorPath; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index afbcf14ca6d..a9e55268253 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -2836,6 +2836,13 @@ class TestCondition : public TestFixture { " }\n" "}\n"); ASSERT_EQUALS("[test.cpp:2:12] -> [test.cpp:4:13]: (warning) Identical inner 'if' condition is always true. [identicalInnerCondition]\n", errout_str()); + + check("int f(const int *q, const int *s) {\n" // #14711 + " if (*q && *s)\n" + " return *q;\n" + " return 0;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void identicalConditionAfterEarlyExit() {