Thanks for this discussion. My simplified example is based on a real code in which a developer really forgot to initialize a private variable and there was no setter. This hidden mystake caused serious problems! That is why I suppose it is rather important to think about the missing warning (and implement the warning somehow).
Reminder, there is no reposnse for almost three weeks... This issue persists in the newest version of CPPCheck, 1.86.
Hi, this topic also covers another false negative of missing warning on uninitialized var. Therefore I decided to add it there. Please, test the following piece of code: class Elem { public: Elem(); ~Elem(); private: int i; } Elem::Elem() //: i(0) // Initialization commented { // Using 'this' in a constructor suppresses warnings about missing initialization of member variables! //pList.reset(new pList( this )); } Running: "C:\Program Files\Cppcheck\cppcheck.exe" --enable=all C:\Users\x\Desktop\reportToCPPCheck\member-var-not-init-missing-warning.cpp...
Hi, this topic also covers another false negative of missing warning on uninitialized var. Therefore I decided to add it there. Please, test the following piece of code: class Elem { public: Elem(); ~Elem(); private: int i; } Elem::Elem() //: i(0) // Initialization commented { // Using 'this' in a constructor suppresses warnings about missing initialization of member variables! //pList.reset(new pList( this )); } Running: "C:\Program Files\Cppcheck\cppcheck.exe" --enable=all C:\Users\x\Desktop\reportToCPPCheck\member-var-not-init-missing-warning.cpp...
Hi, this topic also covers another false negative of missing warning on uninitialized var. Therefore I decided to add it there. Please, test the following piece of code: class Elem { public: Elem(); ~Elem(); private: int i; } Elem::Elem() //: i(0) // Initialization commented { // Using 'this' in a constructor suppresses warnings about missing initialization of member variables! //pList.reset(new pList( this )); } Running "C:\Program Files\Cppcheck\cppcheck.exe" --enable=all C:\Users\x\Desktop\reportToCPPCheck\member-var-not-init-missing-warning.cpp...
Ok. I have something else now. The following code gives: "[test.cpp:13]: (error) Array 'pdispparams->rgvarg[2]' accessed at index 2, which is out of bounds." This error message is suppressed if another assert() is added (just uncomment the last assert and you will see). I do not undersand the behaviour of CPPCheck here. The following fragment of code is compilable in VS2017. #include <atlbase.h> #include <assert.h> class CBBox { public: CBBox() {} STDMETHOD(Invoke)(DISPPARAMS* pdispparams, VARIANT*)...
I agree, you are right. ## is useless in this case. It concatenates an empty token with a token arg1type. Anyway, it is compilable by Visual Studio (at least 2017, without any error or warning). This is a simplified fragment of a legacy code in our huge stream which is going to be replaced soon (I hope). Nevertheless, the point I wrote about this is that I considered Cppcheck encountered a serious internal error (because it "failed") which is good to report. Failure of a program represents a backlog...
Thank you. Nevertheless, amai marked this as a duplicate ticket and closed it. I hope that the developers will finally take care about it.