Fix #12039 FP knownConditionTrueFalse (#5513)

This commit is contained in:
chrchr-github 2023-10-06 09:53:24 +02:00 committed by GitHub
parent 5a52fa80fb
commit 903eccb336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1857,7 +1857,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings* sett
std::vector<ValueFlow::Value> values;
for (const Token* tok2 : tokens) {
if (tok2->hasKnownIntValue()) {
values.emplace_back();
values.emplace_back(tok2->values().front());
} else {
ValueFlow::Value symValue{};
symValue.valueType = ValueFlow::Value::ValueType::SYMBOLIC;

View File

@ -4940,6 +4940,11 @@ private:
" if (j >= 0) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(int i) {\n" // #12039
" if ((128 + i < 255 ? 128 + i : 255) > 0) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {