When I put a delegating constructor outside the class definition cppcheck gives a warning "Member variable is not initialized in the constructor":
classBar{public:Bar();explicitBar(inti);Bar(constBar&other)=delete;~Bar() {}private:string*strs;};Bar::Bar():Bar(100){}// <<---- warning: "Member variable is not initialized"Bar::Bar(inti,boolb):strs(nullptr){}
When I put the delegating constructor inside the class definition everything is fine:
classBar{public:Bar():Bar(100){}// <<----- no warningexplicitBar(inti);Bar(constBar&other)=delete;~Bar() {}private:string*strs;};Bar::Bar(inti,boolb):strs(nullptr){}
Using version 1.69.
Last edit: wibek 2015-05-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I put a delegating constructor outside the class definition cppcheck gives a warning "Member variable is not initialized in the constructor":
When I put the delegating constructor inside the class definition everything is fine:
Using version 1.69.
Last edit: wibek 2015-05-27
Sounds like a bug (false positive). I suggest you file a bug report on http://trac.cppcheck.net/ then.
There seems to be a related ticket already: http://trac.cppcheck.net/ticket/6580
Last edit: Alexander Mai 2015-05-27