Menu

False positive: [unusedFunction] variadic template

2020-07-15
2020-07-15
  • Andreas Grob

    Andreas Grob - 2020-07-15
    struct A {
        int a = 0;
        void f() { a = 1; }
        template <typename T, typename... Args> auto call(const Args &... args) -> T {
            a = 2;
            return T{};
        }
    };
    
    struct B : public A {
        void test() {
            f();
            call<int>(1, 2, 3);
        }
    };
    
    int main() {
        B b;
        b.test();
    }
    

    cppcheck: commit 62702a6
    built with: make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes

    $ cppcheck --enable=all main.cpp
    Checking main.cpp ...
    main.cpp:4:0: style: The function 'call' is never used. [unusedFunction]
    
    ^
    
     

    Last edit: Andreas Grob 2020-07-15
  • Daniel Marjamäki

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

     

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.