From 3f7ecdb0abd38c0be237a825f75e64e9bc8bcc0d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 19 May 2026 09:44:41 +0200 Subject: [PATCH 1/2] Add tests for #6796, #12896 --- test/testcondition.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 9a15349aff0..8a4af8dd6ae 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6472,6 +6472,19 @@ class TestCondition : public TestFixture { " if (INT_MAX > ll * 8) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("bool f(int a, int b) {\n" / #12896 + " if (a < INT_MIN && b > INT_MAX)\n" + " return true;\n" + " return false;\n" + "}\n" + "bool g(int x) {\n" // #6796 + " return (x > INT_MAX) ? true : false;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:13]: (style) Comparing expression of type 'signed int' against value -2147483648. Condition is always false. [compareValueOutOfTypeRangeError]\n" + "[test.cpp:2:28]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n" + "[test.cpp:7:17]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n", + errout_str()); } void knownConditionCast() { From b82c4fdd200c52982a5e3e1aa5b45054c0fe1d4a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 19 May 2026 09:57:07 +0200 Subject: [PATCH 2/2] Update testcondition.cpp --- test/testcondition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 8a4af8dd6ae..8172f74aab6 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6473,7 +6473,7 @@ class TestCondition : public TestFixture { "}\n"); ASSERT_EQUALS("", errout_str()); - check("bool f(int a, int b) {\n" / #12896 + check("bool f(int a, int b) {\n" // #12896 " if (a < INT_MIN && b > INT_MAX)\n" " return true;\n" " return false;\n"