Fix 8358: FP: Condition '(number*0)!=0' is always false (#4065)

This commit is contained in:
Paul Fultz II 2022-04-30 02:35:51 -05:00 committed by GitHub
parent 9fa5c4e201
commit 4e7125554f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -756,7 +756,8 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se
return;
// known result when a operand is 0.
if (Token::Match(parent, "[&*]") && value.isKnown() && value.isIntValue() && value.intvalue==0) {
if (Token::Match(parent, "[&*]") && astIsIntegral(parent, true) && value.isKnown() && value.isIntValue() &&
value.intvalue == 0) {
setTokenValue(parent, value, settings);
return;
}

View File

@ -4094,6 +4094,10 @@ private:
" unsigned long long u{};\n"
"};\n");
ASSERT_EQUALS("", errout.str());
// #8358
check("void f(double d) { if ((d * 0) != 0) {} }");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueSymbolic()