diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1bf64d987..c66ab638c 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1976,7 +1976,7 @@ bool CheckClass::checkConstFunc(const std::string &classname, const Var *varlist } // function call.. - else if (tok1->str() != "return" && Token::Match(tok1, "%var% (")) + else if (tok1->str() != "return" && Token::Match(tok1, "%var% (") && tok1->str() != "c_str") { isconst = false; break; diff --git a/test/testclass.cpp b/test/testclass.cpp index 2b95edf6f..987aa257c 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -3451,7 +3451,7 @@ private: "std::string m_strVal;\n" "};\n" ); - TODO_ASSERT_EQUALS("[test.cpp:4]: (style) The function 'A::strGetString' can be const\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style) The function 'A::strGetString' can be const\n", errout.str()); checkConst("class A{\n" "public:\n" @@ -3462,7 +3462,7 @@ private: "std::string m_strVal;\n" "};\n" ); - TODO_ASSERT_EQUALS("[test.cpp:4]: (style) The function 'A::strGetString1' can be const\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style) The function 'A::strGetString1' can be const\n", errout.str()); } // increment/decrement => not const