From 6fc3b04f77f871772b1df303c61644cab9549e58 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:27:52 +0200 Subject: [PATCH 1/3] Update checkother.cpp --- lib/checkother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 868a9621976..9846710f78a 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1372,7 +1372,7 @@ void CheckOther::checkPassByReference() continue; const bool isConst = var->isConst(); - if (isConst) { + if (isConst && !var->isArray()) { passedByValueError(var, inconclusive, isRangeBasedFor); continue; } From 67f95f056e5b11e997d1a25a9843225dfb8f87dd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:28:59 +0200 Subject: [PATCH 2/3] Update testother.cpp --- test/testother.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index f43cd28a6a8..0770634a037 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2332,6 +2332,10 @@ class TestOther : public TestFixture { " char a[20];\n" "};\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(const std::vector v[2]);\n" // #13052 + "int g(const std::array, 2> a) { return a[0][0]; }\n"); + ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'a' should be passed by const reference.\n", errout_str()); /*const*/ Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build(); check("using ui64 = unsigned __int64;\n" From 39e01b91e2f384026d776cdba6c01a440620a88a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:44:37 +0200 Subject: [PATCH 3/3] Update testother.cpp --- test/testother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testother.cpp b/test/testother.cpp index 0770634a037..51f71b935dd 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2332,7 +2332,7 @@ class TestOther : public TestFixture { " char a[20];\n" "};\n"); ASSERT_EQUALS("", errout_str()); - + check("void f(const std::vector v[2]);\n" // #13052 "int g(const std::array, 2> a) { return a[0][0]; }\n"); ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'a' should be passed by const reference.\n", errout_str());