Menu

False positive uninitMemberVar with deleted default constructor

2024-12-17
2024-12-17
  • Frank Winklmeier

    Another false positive uninitMemberVar in a deleted(!) constructor:

    struct Foo
    {
      Foo() = delete;
      Foo(int an_int) : i(an_int) {}
      ~Foo();
    
      int i;
    };
    
    Foo::~Foo() = default;
    
    > cppcheck --enable=warning test.cxx 
    Checking test.cxx ...
    test.cxx:3:3: warning: Member variable 'Foo::i' is not initialized in the constructor. [uninitMemberVar]
      Foo() = delete;
      ^
    

    Moving the = default into the declaration makes it go away.

     
  • CHR

    CHR - 2024-12-17

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13442

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.