I am getting a false-positive constParameterReference in my constructor where I also have a lambda function which uses a non-const function.
Someclass.hpp: style: Parameter 'dh' can be declared as reference to const [constParameterReference] explicit SomeClass(Handler& dh)
Simplified code:
// constructor explicit SomeClass(Handler& dh) : logTimer_{std::chrono::milliseconds{5000U}} , dialogHndlr_{dh} , cb_{[this](const std::string& input) { dialogHndlr_.Dowork(); return true; }} { } Timer logTimer_; // Dialog handler Handler& dialogHndlr_; Handler::CallbackType cb_;
Dowork- function changes dialogHndlr_, so it's non-const.
When I remove the logtimer, the false-positive is gone.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12733
Log in to post a comment.
I am getting a false-positive constParameterReference in my constructor where I also have a lambda function which uses a non-const function.
Someclass.hpp: style: Parameter 'dh' can be declared as reference to const [constParameterReference]
explicit SomeClass(Handler& dh)
Simplified code:
Dowork- function changes dialogHndlr_, so it's non-const.
When I remove the logtimer, the false-positive is gone.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12733