Skip to content

Commit 04f7a9b

Browse files
Fix #12727 FP knownConditionTrueFalse (wrong range of return values) (danmar#6721)
1 parent b8005e1 commit 04f7a9b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/programmemory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ static bool isIntegralValue(const ValueFlow::Value& value)
602602
static ValueFlow::Value evaluate(const std::string& op, const ValueFlow::Value& lhs, const ValueFlow::Value& rhs)
603603
{
604604
ValueFlow::Value result;
605-
combineValueProperties(lhs, rhs, result);
606605
if (lhs.isImpossible() && rhs.isImpossible())
607606
return ValueFlow::Value::unknown();
608607
if (lhs.isImpossible() || rhs.isImpossible()) {

test/testcondition.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5108,6 +5108,22 @@ class TestCondition : public TestFixture {
51085108
" if ((128 + i < 255 ? 128 + i : 255) > 0) {}\n"
51095109
"}\n");
51105110
ASSERT_EQUALS("", errout_str());
5111+
5112+
check("struct S {\n" // #12727
5113+
" bool f() const {\n"
5114+
" return g() > 0;\n"
5115+
" }\n"
5116+
" std::size_t g() const {\n"
5117+
" return 5 - h();\n"
5118+
" }\n"
5119+
" std::size_t h() const {\n"
5120+
" if (x > 7)\n"
5121+
" return 5;\n"
5122+
" return (5 + x) % 5;\n"
5123+
" }\n"
5124+
" std::size_t x;\n"
5125+
"};\n");
5126+
ASSERT_EQUALS("", errout_str());
51115127
}
51125128

51135129
void alwaysTrueContainer() {

0 commit comments

Comments
 (0)