From ca2a9a8fd624e26b6d80b6c252d08d3687c61167 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:13:11 +0100 Subject: [PATCH 1/3] Update testother.cpp --- test/testother.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 61ff7b2dae5..6908ce4b282 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2367,6 +2367,11 @@ class TestOther : public TestFixture { " return N::f(float_ptr(b.data()));\n" // <- the cast is safe "}\n"); ASSERT_EQUALS("[test.cpp:9:17]: (style) C-style pointer casting [cstyleCast]\n", errout_str()); + + checkOldStylePointerCast("void f(const T& x) {\n" // #13766 + " const U& y = (typename const U&)(x);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:18]: (warning) Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]\n", errout_str()); } #define checkIntToPointerCast(...) checkIntToPointerCast_(__FILE__, __LINE__, __VA_ARGS__) From 0c5a38d2b0588d4f3bc7f526199f0a31dfe16c5e Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:14:09 +0100 Subject: [PATCH 2/3] Update testbufferoverrun.cpp --- test/testbufferoverrun.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 7e12a1ca435..7771d294d2c 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -164,6 +164,7 @@ class TestBufferOverrun : public TestFixture { TEST_CASE(array_index_74); // #11088 TEST_CASE(array_index_75); TEST_CASE(array_index_76); + TEST_CASE(array_index_77); TEST_CASE(array_index_multidim); TEST_CASE(array_index_switch_in_for); TEST_CASE(array_index_for_in_for); // FP: #2634 @@ -2014,6 +2015,21 @@ class TestBufferOverrun : public TestFixture { errout_str()); } + void array_index_77() + { + check("int f(bool b) {\n" // #6092 + " const int a[2] = {};\n" + " int i = 0, s = 0;\n" + " s += a[i++];\n" + " if (b)\n" + " s += a[i++];\n" + " s += a[i++];\n" + " return s + i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7:11]: (error) Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds]\n", + errout_str()); + } + void array_index_multidim() { check("void f()\n" "{\n" From dfa2a4a28c9915a6dccf799fa9184845660df239 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:41:35 +0100 Subject: [PATCH 3/3] Update testunusedvar.cpp --- test/testunusedvar.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 42077399411..65ce7343da0 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -5688,6 +5688,20 @@ class TestUnusedVar : public TestFixture { " a[0].b = 0;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + functionVariableUsage("struct S {\n" // #9995 + " int& operator[](int i) { return r[i]; }\n" + " std::map& r;\n" + "};\n" + "struct T {\n" + " std::map& m;\n" + " S get() { return { m }; }\n" + "};\n" + "void f(T& t) {\n" + " S s = t.get();\n" + " s[1] = 0;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void localvarUnion1() {