From 63d15114a1b20e3868a60205768017a151ec7511 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 18 Feb 2026 10:34:09 +0100 Subject: [PATCH 1/3] Update valueflow.cpp --- lib/valueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ec90fb3e302..09e86b1cb3c 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4531,7 +4531,7 @@ struct ConditionHandler { } // Variable changed in loop code - const Token* const start = top; + const Token* const start = top->strAt(-1) == "for" ? top->astOperand2() : top; // skip init statement const Token* const block = top->link()->next(); const Token* const end = block->link(); From 83c984a09b7576143e6b3fcf2a0807aeabf8fb53 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 18 Feb 2026 10:35:15 +0100 Subject: [PATCH 2/3] Update teststl.cpp --- test/teststl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index c24bf2a5fb1..4694c380493 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1010,6 +1010,12 @@ class TestStl : public TestFixture { ASSERT_EQUALS( "[test.cpp:2:12] -> [test.cpp:4:21]: (warning) Either the condition 'col>textline.size()' is redundant or 'col' can have the value textline.size(). Expression 'textline[col]' causes access out of bounds. [containerOutOfBounds]\n", errout_str()); + + check("void f(const std::vector& v) {\n" // #12742 + " for (unsigned i = 0; i < v.size();)\n" + " (void)v[i++];\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void outOfBoundsIndexExpression() { From 1495c26ef43f05d0c6f95c60577347b01528f6d8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 19 Feb 2026 10:03:33 +0100 Subject: [PATCH 3/3] Format [skip ci] --- test/teststl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/teststl.cpp b/test/teststl.cpp index 4694c380493..cc4856628df 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1013,7 +1013,7 @@ class TestStl : public TestFixture { check("void f(const std::vector& v) {\n" // #12742 " for (unsigned i = 0; i < v.size();)\n" - " (void)v[i++];\n" + " (void)v[i++];\n" "}\n"); ASSERT_EQUALS("", errout_str()); }