Menu

unusedPrivateFunction false positive with friends

Haddayn
2021-09-22
2021-09-24
  • Haddayn

    Haddayn - 2021-09-22

    Found a false positive when a template class is passed as a template parameter to its friend.

    Checking cppcheck.cpp ...
    cppcheck.cpp:14:7: style: Unused private function: 'operations::get' [unusedPrivateFunction]
    void get() {}

    template<typename Operator>
    struct accessor
    {
        void get()
        {
            Operator::get();
        }
    }
    
    template<typename T>
    class operations {
        friend accessor<operations<T>>;
    
        void get() {}
    };
    
     
  • Daniel Marjamäki

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

     

Log in to post a comment.