Skip to content

Commit 76b1011

Browse files
Fix #13524 FP passedByValue for array of std::array (#7175)
1 parent 789c012 commit 76b1011

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/checkother.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ void CheckOther::checkPassByReference()
14161416
if (inconclusive && !mSettings->certainty.isEnabled(Certainty::inconclusive))
14171417
continue;
14181418

1419-
if (var->isArray() && var->getTypeName() != "std::array")
1419+
if (var->isArray() && (!var->isStlType() || Token::simpleMatch(var->nameToken()->next(), "[")))
14201420
continue;
14211421

14221422
const bool isConst = var->isConst();

test/testother.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,9 @@ class TestOther : public TestFixture {
24402440
"int h(const std::array<std::vector<int>, 2> a) { return a[0][0]; }\n");
24412441
ASSERT_EQUALS("[test.cpp:4]: (performance) Function parameter 'a' should be passed by const reference.\n", errout_str());
24422442

2443+
check("void f(const std::array<int, 10> a[]) {}\n"); // #13524
2444+
ASSERT_EQUALS("", errout_str());
2445+
24432446
/*const*/ Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build();
24442447
check("using ui64 = unsigned __int64;\n"
24452448
"ui64 Test(ui64 one, ui64 two) { return one + two; }\n",

0 commit comments

Comments
 (0)