From 8a2f0817902afed93b053ee1835b4ac9305c68f8 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Sat, 4 Jan 2025 12:21:40 +0100 Subject: [PATCH] Fix #13524 FP passedByValue for array of std::array --- lib/checkother.cpp | 2 +- test/testother.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 2612e360cc1..8835f6c6632 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1416,7 +1416,7 @@ void CheckOther::checkPassByReference() if (inconclusive && !mSettings->certainty.isEnabled(Certainty::inconclusive)) continue; - if (var->isArray() && var->getTypeName() != "std::array") + if (var->isArray() && (!var->isStlType() || Token::simpleMatch(var->nameToken()->next(), "["))) continue; const bool isConst = var->isConst(); diff --git a/test/testother.cpp b/test/testother.cpp index 1b636dd962d..a04095ceab8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2440,6 +2440,9 @@ class TestOther : public TestFixture { "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()); + check("void f(const std::array a[]) {}\n"); + ASSERT_EQUALS("", errout_str()); + /*const*/ Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build(); check("using ui64 = unsigned __int64;\n" "ui64 Test(ui64 one, ui64 two) { return one + two; }\n",