diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 37f23d417..08d22e673 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1424,7 +1424,7 @@ void CheckOther::checkConstVariable() continue; if (var->isStatic()) continue; - if (var->isArray()) + if (var->isArray() && !var->isStlType()) continue; if (var->isEnumType()) continue; diff --git a/test/testother.cpp b/test/testother.cpp index 320279ff6..1530a3a36 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3107,6 +3107,14 @@ private: " }\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(std::array& a) {\n" + " if (a[0]) {}\n" + "}\n" + "void g(std::array& a) {\n" + " a.fill(0);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'a' can be declared as const array\n", errout.str()); } void constParameterCallback() {