Fix 10708: Assertion "!maxValue->isKnown()" from valueFlowInferCondition (#3736)
* Fix 10708: Assertion "!maxValue->isKnown()" from valueFlowInferCondition * Format
This commit is contained in:
parent
57b50e4b00
commit
0737cc4d8c
|
@ -2126,7 +2126,7 @@ bool Token::addValue(const ValueFlow::Value &value)
|
|||
});
|
||||
}
|
||||
|
||||
// assert(!value.isPossible() || !mImpl->mValues || std::none_of(mImpl->mValues->begin(), mImpl->mValues->end(),
|
||||
// assert(value.isKnown() || !mImpl->mValues || std::none_of(mImpl->mValues->begin(), mImpl->mValues->end(),
|
||||
// [&](const ValueFlow::Value& x) {
|
||||
// return x.isKnown() && sameValueType(x, value);
|
||||
// }));
|
||||
|
|
|
@ -4450,7 +4450,7 @@ static std::vector<const Token*> getConditions(const Token* tok, const char* op)
|
|||
return false;
|
||||
if (tok2->hasKnownIntValue())
|
||||
return false;
|
||||
if (Token::Match(tok2, "%var%") && !astIsBool(tok2))
|
||||
if (Token::Match(tok2, "%var%|.") && !astIsBool(tok2))
|
||||
return false;
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -6197,6 +6197,20 @@ private:
|
|||
"};\n"
|
||||
"void d::c(int) { e.clear(); }\n";
|
||||
valueOfTok(code, "e");
|
||||
|
||||
code = "struct a {\n"
|
||||
" int b;\n"
|
||||
" int c;\n"
|
||||
"} f;\n"
|
||||
"unsigned g;\n"
|
||||
"struct {\n"
|
||||
" a d;\n"
|
||||
"} e;\n"
|
||||
"void h() {\n"
|
||||
" if (g && f.c)\n"
|
||||
" e.d.b = g - f.c;\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "e");
|
||||
}
|
||||
|
||||
void valueFlowHang() {
|
||||
|
|
Loading…
Reference in New Issue