Menu

False positive: [functionStatic] variadic template

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

    Andreas Grob - 2020-07-15
    struct A {
        int a = 0;
        template <typename... Args> void call(const Args &... args) { a = 1; }
        template <typename T, typename... Args> auto call(const Args &... args) -> T {
            a = 2;
            return T{};
        }
    };
    
    struct B : public A {
        void test() {
            call();
            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 --inconclusive main.cpp
    Checking main.cpp ...
    main.cpp:11:10: performance:inconclusive: Technically the member function 'B::test' can be static (but you may consider moving to unnamed namespace). [functionStatic]                        
        void test() {
             ^
    

    This might be the same issue as with False positive: [unusedFunction] variadic template, but I can't be sure, so I am posting both.

     
  • Daniel Marjamäki

    Thanks! I created a ticket: https://trac.cppcheck.net/ticket/9806

     

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.