Menu

[[maybe_unused]] does not suppress unusedPrivateFunction

2022-11-10
2022-11-10
  • Artem Amirkhanov

    First, thank you for making cppcheck :)

    Following snippet produces "unused private function" [unusedPrivateFunction] style warning, despite the use of [[maybe_unused]] attribute which one could expect to be recognized by cppcheck based on this post: https://sourceforge.net/p/cppcheck/news/2021/04/c17-support-in-cppcheck/

    class Foo
    {
    private:
        [[maybe_unused]] int Return42() { return 42; }
    };
    
    void f()
    {
        [[maybe_unused]] Foo foo;
    }
    

    I tested with cppcheck 2.9 and was able to reproduce in online demo tool.

     

    Last edit: Artem Amirkhanov 2022-11-10
  • CHR

    CHR - 2022-11-10

    Thanks for reporting, fixed by https://github.com/danmar/cppcheck/pull/4579

     

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.