diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 1b5c51c0d..72653049f 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1124,11 +1124,15 @@ static ExprEngine::ValuePtr executeCast(const Token *tok, Data &data) return std::make_shared(data.getNewSymbolName(), bufferSize, range, true, nullPointer, uninitPointer); } - if (val) + if (val) { // TODO: Cast this.. + call(data.callbacks, tok, val, &data); return val; + } - return getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings); + val = getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings); + call(data.callbacks, tok, val, &data); + return val; } static ExprEngine::ValuePtr executeDot(const Token *tok, Data &data) diff --git a/test/testsuites/danmar-verify/divbyzero.cpp b/test/testsuites/danmar-verify/divbyzero.cpp index dfe7fd41a..e53d03515 100644 --- a/test/testsuites/danmar-verify/divbyzero.cpp +++ b/test/testsuites/danmar-verify/divbyzero.cpp @@ -9,7 +9,7 @@ void pointer2(int *p) { return 100000 / p[32]; } -void float(float f) { +void float1(float f) { // cppcheck-suppress verificationDivByZero return 100000 / (int)f; } @@ -19,7 +19,7 @@ void stdmap(std::map &data) { return 100000 / data[43]; } -struct S { int x }; +struct S { int x; }; void struct1(struct S *s) { // cppcheck-suppress verificationDivByZero return 100000 / s->x;