From 2f9bc5433071f571c063b33d859790fefd0a6050 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:50:04 +0100 Subject: [PATCH 1/2] Update checkother.cpp --- lib/checkother.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 155464d5aab..36d7c76acee 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1407,8 +1407,11 @@ void CheckOther::checkPassByReference() if (inconclusive && !mSettings->certainty.isEnabled(Certainty::inconclusive)) continue; + if (var->isArray() && var->getTypeName() != "std::array") + continue; + const bool isConst = var->isConst(); - if (isConst && !var->isArray()) { + if (isConst) { passedByValueError(var, inconclusive, isRangeBasedFor); continue; } From 654d09a173b53d3153718a0be8f8a8f4faeb4ea0 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:50:58 +0100 Subject: [PATCH 2/2] Update testother.cpp --- test/testother.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/testother.cpp b/test/testother.cpp index 4dfb00ac03b..1a4d10c4f16 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2435,8 +2435,10 @@ class TestOther : public TestFixture { 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()); + "void g(const std::vector v[2]);\n" + "void g(const std::vector v[2]) {}\n" + "int h(const std::array, 2> a) { return a[0][0]; }\n"); + ASSERT_EQUALS("[test.cpp:4]: (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"