From d0bf6bcf06ef9411e6aa14312c0c42389f06f4d1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 13:23:20 +0200 Subject: [PATCH 1/3] Update checkcondition.cpp --- lib/checkcondition.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 570575b4682..5fc81791bbb 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1970,6 +1970,8 @@ void CheckCondition::checkCompareValueOutOfTypeRange() continue; if (valueTok->getKnownIntValue() < 0 && valueTok->valueType() && valueTok->valueType()->sign != ValueType::Sign::SIGNED) continue; + if (typeTok->isLiteral()) + continue; std::uint8_t bits = 0; switch (typeTok->valueType()->type) { case ValueType::Type::BOOL: From 93ca67e55a07695c7a1ed4099cad1f020d6b8516 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 13:31:08 +0200 Subject: [PATCH 2/3] Update testcondition.cpp --- test/testcondition.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 58475896ebe..7a754c2a8e9 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6375,6 +6375,13 @@ class TestCondition : public TestFixture { ASSERT_EQUALS("[test.cpp:3:14]: (style) Comparing expression of type 'const unsigned int &' against value 4294967295. Condition is always true. [compareValueOutOfTypeRangeError]\n" "[test.cpp:4:13]: (style) Comparing expression of type 'const unsigned int &' against value 4294967295. Condition is always false. [compareValueOutOfTypeRangeError]\n", errout_str()); + + check("void f() {\n" + " long long ll = 1024 * 1024 * 1024;\n" + " if (ll * 8 < INT_MAX) {}\n" + " if (INT_MAX > ll * 8) {}\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void knownConditionCast() { From 590df8aff9e9610ad2c6663e3abafb48f909a889 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 13:37:57 +0200 Subject: [PATCH 3/3] Update std.c --- test/cfg/std.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cfg/std.c b/test/cfg/std.c index af0b30e03b2..e8dcec1be6c 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -45,7 +45,7 @@ void test_int32_min() { } void test_int64_min() { - // cppcheck-suppress compareValueOutOfTypeRangeError ; tests that INT64_MIN is a signed expression + // TODO cppcheck-suppress knownConditionTrueFalse // #13814 if (INT64_MIN < 0) {} }