cppcheck 2.22.0 generates noDestructor for the following code:
#include <windows.h> class NonCopyable { protected: NonCopyable() {} private: NonCopyable(const NonCopyable&); NonCopyable& operator=(const NonCopyable&); }; class Brush : public NonCopyable { private: HBRUSH m_brush; public: explicit Brush(HBRUSH brush) : m_brush(brush) {} ~Brush() { if (m_brush) DeleteObject(m_brush); } }; class GDI : public NonCopyable { private: Brush m_brush; public: GDI() : m_brush(CreateSolidBrush(RGB(0, 0, 0))) {} }; int main() { return 0; }
cppcheck.exe --library=windows --enable=all .
test\main.cpp:30:10: warning: Class 'GDI' does not have a destructor which is recommended since it has dynamic memory/resource management. [noDestructor] GDI() : m_brush(CreateSolidBrush(RGB(0, 0, 0))) {} ^
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15057
Log in to post a comment.
cppcheck 2.22.0 generates noDestructor for the following code:
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15057