diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index aa0b2c91c29..4a465172dcf 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -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"