diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index aa0b2c91c29..7af430fdce3 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -727,7 +727,7 @@ static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) } if (!var) continue; - if (!var->isArray() || var->isArgument() || var->isStlType()) + if (!var->isArray() || var->isArgument() || var->getTypeName() == "std::array") continue; if (isNonZero(getOtherOperand(tok)) && Token::Match(tok->astParent(), "%comp%")) continue; @@ -1169,7 +1169,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett value.setImpossible(); setTokenValue(tok, std::move(value), settings); } else if (tok->variable() && tok->variable()->isArray() && !tok->variable()->isArgument() && - !tok->variable()->isStlType()) { + tok->variable()->getTypeName() != "std::array") { ValueFlow::Value value{0}; value.setImpossible(); setTokenValue(tok, std::move(value), settings); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index c7f39584939..d8fe988db35 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3449,6 +3449,12 @@ class TestCondition : public TestFixture { "}\n"); ASSERT_EQUALS("", errout_str()); + check("std::string a[3];\n" // #15065 + "void f() {\n" + " if (a) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:8]: (style) Condition 'a' is always true [knownConditionTrueFalse]\n", errout_str()); + // Avoid FP when condition comes from macro check("#define NOT !\n" "void f() {\n"