diff --git a/lib/library.cpp b/lib/library.cpp index 7520944d8ad..2a198001d3c 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1781,6 +1781,8 @@ bool Library::isFunctionConst(const Token *ftok) const const Yield yield = astContainerYield(ftok->astParent()->astOperand1(), *this); if (yield == Yield::EMPTY || yield == Yield::SIZE || yield == Yield::BUFFER_NT) return true; + if ((yield == Yield::START_ITERATOR || yield == Yield::END_ITERATOR) && ftok->str()[0] == 'c') + return true; } return false; } diff --git a/test/testother.cpp b/test/testother.cpp index 93e67229f43..ed48b181715 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4864,6 +4864,11 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:1:12]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n" "[test.cpp:1:20]: (style) Parameter 'q' can be declared as pointer to const [constParameterPointer]\n", errout_str()); + + check("int f(std::vector* p) {\n" // #14810 + " return *p->cbegin();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:1:25]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); } void constArray() {