From ee2cb98453cf3f4b70223f82432459efcff021a5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Oct 2025 14:03:14 +0200 Subject: [PATCH 1/3] Update checkclass.cpp --- lib/checkclass.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index bf2ff16613c..9442d44cebf 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1226,6 +1226,10 @@ void CheckClass::initializationListUsage() allowed = false; return ChildrenToVisit::done; } + if (var2->isLocal() && isVariableChanged(var2->nameToken(), previousBeforeAstLeftmostLeaf(tok), var2->declarationId(), /*globalvar*/ false, *mSettings)) { + allowed = false; + return ChildrenToVisit::done; + } } else if (tok2->str() == "this") { // 'this' instance is not completely constructed in initialization list allowed = false; return ChildrenToVisit::done; From ceff00e47e94b6f2efacafff2aa8c36984ef5605 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Oct 2025 14:12:03 +0200 Subject: [PATCH 2/3] Update testclass.cpp --- test/testclass.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index 6ae06b3907e..e9cda486871 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8119,6 +8119,21 @@ class TestClass : public TestFixture { " std::string st;\n" "};"); ASSERT_EQUALS("", errout_str()); + + checkInitializationListUsage("struct S {\n" // #14189 + " S() {}\n" + " int i{};\n" + "};\n" + "struct T { explicit T(const S&); };\n" + "class C {\n" + " C() {\n" + " S s;\n" + " s.i = 1;\n" + " p = std::make_unique(s); + " }\n" + " std::unique_ptr p;\n" + "};"); + ASSERT_EQUALS("", errout_str()); } From f49f24e0398f92db0bd7842149430c5afad47ad8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Oct 2025 14:36:49 +0200 Subject: [PATCH 3/3] Update testclass.cpp --- test/testclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testclass.cpp b/test/testclass.cpp index e9cda486871..7494fe9edc2 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8129,7 +8129,7 @@ class TestClass : public TestFixture { " C() {\n" " S s;\n" " s.i = 1;\n" - " p = std::make_unique(s); + " p = std::make_unique(s);\n" " }\n" " std::unique_ptr p;\n" "};");