Menu

False negative: duplInheritedMember

CHR
2020-10-27
2020-10-27
  • CHR

    CHR - 2020-10-27

    Apparently, cppcheck only looks for duplicate member names within the the immediate base class. Maybe a larger hierarchy could also be supported?

    struct Base {
        int i{};
    };
    
    struct Derived : public Base {
        int j{}; // rename to i to get warnings about both Derived and Derived2
    };
    
    struct Derived2 : public Derived {
        int i{}; //no warning here
    };
    
    int main() {
        Derived2 d2;
        return d2.i;
    }
    
     
  • Daniel Marjamäki

    Thanks! I have created ticket https://trac.cppcheck.net/ticket/9957

    I have the feeling this is relatively simple to fix. Please feel free to investigate..

     

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.