From dada503afcd3b36e71f0781a2bffc75c6f34eac6 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:54:52 +0100 Subject: [PATCH 1/6] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 27c27934f31..ec54b8efde0 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -228,7 +228,8 @@ struct ValueFlowAnalyzer : Analyzer { if (inconclusive) return Action::Read | Action::Inconclusive; if (isVariableChanged(tok, getIndirect(tok), getSettings())) { - if (Token::Match(tok->astParent(), "*|[|.|++|--")) + if (Token::Match(tok->astParent(), "*|[|.|++|--") || + (tok->astParent() && tok->astParent()->isAssignmentOp() && tok->astParent()->str().size() == 2)) // compound assignment return Action::Read | Action::Invalid; // Check if its assigned to the same value if (value && !value->isImpossible() && Token::simpleMatch(tok->astParent(), "=") && astIsLHS(tok) && From 30484de423b3a99b622eec52296d6853203273bd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:55:41 +0100 Subject: [PATCH 2/6] Update testnullpointer.cpp --- test/testnullpointer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index ca5c183c911..111e04c35f6 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -4707,7 +4707,7 @@ class TestNullPointer : public TestFixture { " p += a;\n" " *p = 0;\n" "}\n"); - ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS("[test.cpp:2:7]: (error) Pointer addition with NULL pointer. [nullPointerArithmetic]\n", errout_str()); check("int f(int *p = 0) {\n" " if (p == 0) {\n" From 58126147d4cc2152fd0934d6c8863a4f9ca22b55 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:56:26 +0100 Subject: [PATCH 3/6] Update testvalueflow.cpp --- test/testvalueflow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 3609bf2aee2..392c5cef551 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1110,6 +1110,12 @@ class TestValueFlow : public TestFixture { " g(std::move(x)).f(1);\n" "}\n"; ASSERT_EQUALS(false, testValueOfX(code, 5U, ValueFlow::Value::MoveKind::MovedVariable)); + + code = "void f(std::string x) {\n" // #15155 + " std::string a{ std::move(x) };\n" + " x += \"abc\";\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfX(code, 3U, ValueFlow::Value::MoveKind::MovedVariable)); } void valueFlowCalculations() { From bbbd6e51a1c266fbfc42552c25049d070839775e Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:17:13 +0100 Subject: [PATCH 4/6] Update vf_analyzers.cpp [skip ci] --- lib/vf_analyzers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index ec54b8efde0..b3e692be891 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -229,7 +229,7 @@ struct ValueFlowAnalyzer : Analyzer { return Action::Read | Action::Inconclusive; if (isVariableChanged(tok, getIndirect(tok), getSettings())) { if (Token::Match(tok->astParent(), "*|[|.|++|--") || - (tok->astParent() && tok->astParent()->isAssignmentOp() && tok->astParent()->str().size() == 2)) // compound assignment + (Token::Match(tok->astParent(), "%assign%") && tok->astParent()->str().size() > 1)) // compound assignment return Action::Read | Action::Invalid; // Check if its assigned to the same value if (value && !value->isImpossible() && Token::simpleMatch(tok->astParent(), "=") && astIsLHS(tok) && From 28c5e6587c5c8c300212ff96676e27690cb70ebd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:18:14 +0100 Subject: [PATCH 5/6] Update testuninitvar.cpp [skip ci] --- test/testuninitvar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 4d1a913ed3a..31581ce62a2 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6846,6 +6846,15 @@ class TestUninitVar : public TestFixture { " return a[0];\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + valueFlowUninit("void f(int i) {\n" + " int x, y;\n" + " x += i;\n" + " y <<= i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Uninitialized variable: x [uninitvar]\n" + "[test.cpp:4:5]: (error) Uninitialized variable: y [uninitvar]\n", + errout_str()); } void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value From 811a54c90d710e1e6afdd83ec136640218b3e273 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Nov 2026 14:19:25 +0100 Subject: [PATCH 6/6] Update testvalueflow.cpp --- test/testvalueflow.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 392c5cef551..7ec73a4868f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1116,6 +1116,16 @@ class TestValueFlow : public TestFixture { " x += \"abc\";\n" "}\n"; ASSERT_EQUALS(true, testValueOfX(code, 3U, ValueFlow::Value::MoveKind::MovedVariable)); + + code = "struct S {\n" + " S& operator<<=(int i);\n" + " std::string m;\n" + "};\n" + "void f(S x) {\n" + " S a{ std::move(x) };\n" + " x <<= 5;\n" + "}"; + ASSERT_EQUALS(true, testValueOfX(code, 7U, ValueFlow::Value::MoveKind::MovedVariable)); } void valueFlowCalculations() {