Fix 11669: Assert failure in infer.cpp (#4982)

* Fix 11669: Assert failure in infer.cpp

* Format
This commit is contained in:
Paul Fultz II 2023-04-18 11:35:25 -05:00 committed by GitHub
parent 4183336dc1
commit 6031bed5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -148,7 +148,7 @@ struct Interval {
result.setMinValue(minValue->intvalue + 1, minValue);
if (minValue->isPossible() && minValue->bound == ValueFlow::Value::Bound::Lower)
result.setMinValue(minValue->intvalue, minValue);
if (!minValue->isImpossible() && minValue->bound == ValueFlow::Value::Bound::Point &&
if (!minValue->isImpossible() && (minValue->bound == ValueFlow::Value::Bound::Point || minValue->isKnown()) &&
std::count_if(values.begin(), values.end(), predicate) == 1)
return Interval::fromInt(minValue->intvalue, minValue);
}

View File

@ -7183,6 +7183,17 @@ private:
" a;\n"
"}\n";
valueOfTok(code, "a");
code = "void f(int i, int j, int n) {\n"
" if ((j == 0) != (i == 0)) {}\n"
" int t = 0;\n"
" if (j > 0) {\n"
" t = 1;\n"
" if (n < j)\n"
" n = j;\n"
" }\n"
"}\n";
valueOfTok(code, "i");
}
void valueFlowCrashConstructorInitialization() { // #9577