Hello experts,
Recently I'm trying to use the cppcheck to do some analysis of code, and got following question:
Sample of code:
#include<string>usingnamespacestd;classA{public:staticA&getInstance(){returntheInstance;}stringgetValue();private:staticAtheInstance;};stringgetValue();constchar*get(){constchar*theAns;//theAns=getValue().c_str();/// When use the plain function call could get the expect warning resulttheAns=A::getInstance().getValue().c_str();/// But not for this one.returntheAns;}intmain(){contchar*a=get();printf("a=%s\n",a);return1;}
Could you help check if cppcheck support such scenario?
Thanks,
Mark
Last edit: mark zhang 2024-08-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello experts,
Recently I'm trying to use the cppcheck to do some analysis of code, and got following question:
Sample of code:
Could you help check if cppcheck support such scenario?
Thanks,
Mark
Last edit: mark zhang 2024-08-07
Got answer, the latest version 2.14 could warn on this case.
But I used version 2.4.
Thanks,
Mark