diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 788a20bb7..df3632683 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -598,7 +598,7 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se // cast.. if (const Token *castType = getCastTypeStartToken(parent)) { if (((tok->valueType() == nullptr && value.isImpossible()) || astIsPointer(tok)) && - value.valueType == ValueFlow::Value::ValueType::INT && + contains({ValueFlow::Value::ValueType::INT, ValueFlow::Value::ValueType::SYMBOLIC}, value.valueType) && Token::simpleMatch(parent->astOperand1(), "dynamic_cast")) return; const ValueType &valueType = ValueType::parseDecl(castType, settings); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 59a85f084..29078d3ad 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3914,6 +3914,19 @@ private: " if (m_PC->GetI() != I) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #10624 + check("struct Data {\n" + " Base* PBase{};\n" + "};\n" + "void f(Data* BaseData) {\n" + " Base* PObj = BaseData->PBase;\n" + " if (PObj == nullptr)\n" + " return;\n" + " Derived* pD = dynamic_cast(PObj);\n" + " if (pD) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueInfer() {