Menu

False positive on templated lambda call

2023-07-20
2023-07-21
  • Sylvain Joubert

    Sylvain Joubert - 2023-07-20

    I know there was some recent fixes on C++20 templated lambda, so this may already be fixed. But that seems a slightly different use case, so I prefer to report it as well.

    $ cppcheck --version
    Cppcheck 2.11
    
    $ cat test.cpp 
    int main()
    {
      auto test = []<typename T, typename U>(int)
      {
      };
      test.operator()<int, int>(42);
    }
    
    $ cppcheck --enable=style --std=c++20 test.cpp 
    Checking test.cpp ...
    test.cpp:6:22: warning: Found suspicious operator ',', result is not used. [constStatement]
      test.operator()<int, int>(42);
                         ^
    

    This is a weird case of the lambda having template specifier that are not deduced from the parameter call. So one has to explicitly call operator() with the template parameters.

     
  • CHR

    CHR - 2023-07-20

    https://trac.cppcheck.net/ticket/11840
    Have you considered getting a trac account?

     
    • Sylvain Joubert

      Sylvain Joubert - 2023-07-21

      Yes, a couple years ago. But the account creation could be simpler than having to send a password hash to the maintainer so I gave up. I'll look into creating an account again. Thanks for following with the bug reports so far :-)

       

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.