Menu

False positive: functionConst [inconclusive]

CHR
2020-09-15
2021-01-28
  • CHR

    CHR - 2020-09-15

    If you call a method on a subobject which takes a member of a different subobject by non-const reference, cppcheck reports that the top method can be const:

    struct Foo {
        Bar bar;
        Baz baz;
        int i{};
        void getInt() { bar.getInt(baz.i); } // Technically the member function 'Foo::getInt' can be const
    };
    
    struct Bar {
        int j = 5;
        void getInt(int& i) const { i += j; }
    };
    
    struct Baz {
        int i{};
    };
    
     
  • CHR

    CHR - 2021-01-25

    This still reproduces with v2.3.

     
  • CHR

    CHR - 2021-01-28
     

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.