Fixed #5965 (False positive zerodiv - loop iterating over double variable)
This commit is contained in:
parent
d3425d5c61
commit
15bb447fdc
|
@ -943,8 +943,11 @@ static void execute(const Token *expr,
|
|||
if (!expr)
|
||||
*error = true;
|
||||
|
||||
else if (expr->isNumber())
|
||||
else if (expr->isNumber()) {
|
||||
*result = MathLib::toLongNumber(expr->str());
|
||||
if (MathLib::isFloat(expr->str()))
|
||||
*error = true;
|
||||
}
|
||||
|
||||
else if (expr->varId() > 0) {
|
||||
const std::map<unsigned int, MathLib::bigint>::const_iterator var = programMemory->find(expr->varId());
|
||||
|
|
|
@ -939,6 +939,13 @@ private:
|
|||
" x;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0));
|
||||
|
||||
code = "void foo(double recoveredX) {\n"
|
||||
" for (double x = 1e-18; x < 1e40; x *= 1.9) {\n"
|
||||
" double relativeError = (x - recoveredX) / x;\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
|
||||
}
|
||||
|
||||
void valueFlowSubFunction() {
|
||||
|
|
Loading…
Reference in New Issue