⚡ Sangsakala Proxy 🏠 Home
Skip to content

Commit f747863

Browse files
committed
Fix
1 parent 45944b9 commit f747863

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎lib/valueflow.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,8 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
10981098
bool nonNull = false;
10991099
for (const Token *op : {tok->astOperand1(), tok->astOperand2()}) {
11001100
for (const ValueFlow::Value& v : op->values()) {
1101+
if (!op->valueType() || !op->valueType()->isIntegral())
1102+
continue;
11011103
if (v.valueType != ValueFlow::Value::ValueType::INT)
11021104
continue;
11031105
if ((v.isKnown() && v.intvalue != 0) || (v.isImpossible() && v.intvalue == 0)) {

‎test/testvalueflow.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,6 +4439,12 @@ class TestValueFlow : public TestFixture {
44394439
" return x;\n"
44404440
"}\n";
44414441
ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, 0));
4442+
4443+
code = "bool f(const std::optional<bool>& o) {\n"
4444+
" const bool x = o | []() { return std::make_optional(false); };\n"
4445+
" return x;\n"
4446+
"}\n";
4447+
ASSERT_EQUALS(false, testValueOfXImpossible(code, 3U, 0));
44424448
}
44434449

44444450
void valueFlowForwardInconclusiveImpossible() {

0 commit comments

Comments
 (0)