diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 58fbe0b6d61..24b1fea3274 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -676,7 +676,7 @@ struct ValueFlowAnalyzer : Analyzer { std::vector evaluateInt(const Token* tok, F getProgramMemory) const { if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) - return {static_cast(v->intvalue)}; + return {v->intvalue}; std::vector result; ProgramMemory pm = getProgramMemory(); if (Token::Match(tok, "&&|%oror%")) { @@ -717,7 +717,7 @@ struct ValueFlowAnalyzer : Analyzer { ProgramMemory pm = pms.get(tok, ctx, getProgramState()); MathLib::bigint out = 0; if (pm.getContainerEmptyValue(tok->exprId(), out)) - return {static_cast(out)}; + return {out}; return {}; } return {}; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 9586e4fdca2..b8b31e8d248 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -320,7 +320,7 @@ class TestValueFlow : public TestFixture { } #define testValueOfX(...) testValueOfX_(__FILE__, __LINE__, __VA_ARGS__) - bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, int value, const Settings *s = nullptr) { + bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, MathLib::bigint value, const Settings *s = nullptr) { const Settings *settings1 = s ? s : &settings; // Tokenize.. @@ -3973,6 +3973,14 @@ class TestValueFlow : public TestFixture { " return x;\n" "}"; ASSERT_EQUALS(true, testValueOfX(code, 4U, 246)); + + code = "int64_t f() {\n" + " const int64_t val = 1LL << 33;\n" + " int64_t x = val;\n" + " x += val;\n" + " return x;\n" + "}"; + ASSERT_EQUALS(true, testValueOfX(code, 5U, 1LL << 34)); } void valueFlowForwardCorrelatedVariables() {