diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 8ec3a8ab9..95bdd8209 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -2108,6 +2108,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, return; if (tok->hasKnownIntValue() && tok->getKnownIntValue() != 0) return; + if (tok->isImpossibleIntValue(0)) + return; if (value.isUninit()) return; float f = getKnownFloatValue(tok, 0.0f); diff --git a/lib/token.h b/lib/token.h index cb571093f..0ad9f3672 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1032,6 +1032,19 @@ public: return mImpl->mValues->front().intvalue; } + bool isImpossibleIntValue(const MathLib::bigint val) const { + if (!mImpl->mValues) + return false; + for (const auto &v: *mImpl->mValues) { + if (v.isIntValue() && v.isImpossible() && v.intvalue == val) + return true; + if (v.isIntValue() && v.bound == ValueFlow::Value::Bound::Lower && v.intvalue > val) + return true; + if (v.isIntValue() && v.bound == ValueFlow::Value::Bound::Upper && v.intvalue < val) + return true; + } + } + const ValueFlow::Value * getValue(const MathLib::bigint val) const { if (!mImpl->mValues) return nullptr;