Skip to content

Commit ecc1b44

Browse files
Fix #13052 FP passedByValue for array of vectors (#6730)
1 parent 4ba0767 commit ecc1b44

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ void CheckOther::checkPassByReference()
13721372
continue;
13731373

13741374
const bool isConst = var->isConst();
1375-
if (isConst) {
1375+
if (isConst && !var->isArray()) {
13761376
passedByValueError(var, inconclusive, isRangeBasedFor);
13771377
continue;
13781378
}

test/testother.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,10 @@ class TestOther : public TestFixture {
23332333
"};\n");
23342334
ASSERT_EQUALS("", errout_str());
23352335

2336+
check("void f(const std::vector<int> v[2]);\n" // #13052
2337+
"int g(const std::array<std::vector<int>, 2> a) { return a[0][0]; }\n");
2338+
ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'a' should be passed by const reference.\n", errout_str());
2339+
23362340
/*const*/ Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build();
23372341
check("using ui64 = unsigned __int64;\n"
23382342
"ui64 Test(ui64 one, ui64 two) { return one + two; }\n",

0 commit comments

Comments
 (0)