Skip to content

Commit

Permalink
Fix #13524 FP passedByValue for array of std::array
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 4, 2025
1 parent dfce062 commit 8a2f081
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,9 @@ class TestOther : public TestFixture {
"int h(const std::array<std::vector<int>, 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<int, 10> 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",
Expand Down

0 comments on commit 8a2f081

Please sign in to comment.