From dcee438a10b30b62b58827c476798b37938d3d38 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 09:50:47 +0200 Subject: [PATCH 1/2] Update astutils.cpp --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index c745d0cf9f2..94dc6fc5afa 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1816,7 +1816,7 @@ static bool isZeroBoundCond(const Token * const cond, bool reverse) const Token* op = reverse ? cond->astOperand1() : cond->astOperand2(); if (!op->hasKnownIntValue()) - return false; + return true; // Assume unsigned const bool isZero = op->getKnownIntValue() == 0; From d6b44d912eca51396930683ef9c1834457b30b6d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 09:51:51 +0200 Subject: [PATCH 2/2] Update testcondition.cpp --- test/testcondition.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 9737217add3..fae9c8fce13 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -2682,6 +2682,12 @@ class TestCondition : public TestFixture { check("void f1(const std::string &s) { if(s.empty()) if(42 < s.size()) {}}"); ASSERT_EQUALS("[test.cpp:1:43] -> [test.cpp:1:53]: (warning) Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]\n", errout_str()); + check("void f(const std::string& s, int n) {\n" // #14716 + " if (s.size() < n)\n" + " if (s.empty()) {}\n" + "}"); + ASSERT_EQUALS("", errout_str()); + // TODO: These are identical condition since size cannot be negative check("void f1(const std::string &s) { if(s.size() <= 0) if(s.empty()) {}}"); ASSERT_EQUALS("", errout_str());