10278: ValueFlow: Wrong known value, sign conversion (#3260)
This commit is contained in:
parent
84f8b7b50a
commit
4b11bb4ad3
|
@ -1461,7 +1461,7 @@ static std::vector<MathLib::bigint> minUnsignedValue(const Token* tok, int depth
|
|||
return result;
|
||||
if (tok->hasKnownIntValue()) {
|
||||
result = {tok->values().front().intvalue};
|
||||
} else if (tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
||||
} else if (tok->str() != "-" && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
||||
std::vector<MathLib::bigint> op1 = minUnsignedValue(tok->astOperand1(), depth - 1);
|
||||
std::vector<MathLib::bigint> op2 = minUnsignedValue(tok->astOperand2(), depth - 1);
|
||||
if (!op1.empty() && !op2.empty()) {
|
||||
|
|
|
@ -3620,6 +3620,12 @@ private:
|
|||
" g(name);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) Condition 'name.empty()' is always true\n", errout.str());
|
||||
|
||||
// #10278
|
||||
check("void foo(unsigned int x) {\n"
|
||||
" if ((100 - x) > 0) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueInfer() {
|
||||
|
|
Loading…
Reference in New Issue