Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13052 FP passedByValue for array of vectors #6730

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ void CheckOther::checkPassByReference()
continue;

const bool isConst = var->isConst();
if (isConst) {
if (isConst && !var->isArray()) {
passedByValueError(var, inconclusive, isRangeBasedFor);
continue;
}
Expand Down
4 changes: 4 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,10 @@ class TestOther : public TestFixture {
"};\n");
ASSERT_EQUALS("", errout_str());

check("void f(const std::vector<int> v[2]);\n" // #13052
"int g(const std::array<std::vector<int>, 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"
"ui64 Test(ui64 one, ui64 two) { return one + two; }\n",
Expand Down
Loading