Menu

False positive unusedPrivateFunction when using trailing return type while overriding a virtual function

Frank
2024-04-16
2024-04-16
  • Frank

    Frank - 2024-04-16

    I get a possible false positive warning when using trailing return type while overriding a virtual function.

    warning: Unused private function: 'Test::PrivateTest' [unusedPrivateFunction]

    #ifndef TEST_H
    #define TEST_H
    
    class BaseTest {
    public:  
      virtual auto Testing() -> void = 0;
    };
    
    class Test final : public BaseTest {
    private:
      auto PrivateTest() -> void;
    public:
      auto Testing() -> void override;
    };
    
    #endif // TEST_H
    
    auto Test::PrivateTest() -> void {
      return;
    }
    
    auto Test::Testing() -> void {
      PrivateTest();
    }
    

    When I don't use trailing return type in the public function definition, I don't get any warning.
    Also no warning when removing the override.

     
  • CHR

    CHR - 2024-04-16

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12619

     

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.