Menu

cppcheck doesn't recognise final in a class definition as implying functions in the class are final

T Tanner
2022-07-02
2022-07-05
  • T Tanner

    T Tanner - 2022-07-02

    So when I have something like

    struct Y: { virtual void wibble() = 0; virtual ~Y() {} };
    
    struct X final: public Y { void wibble() override;  X() {} virtual ~X() { wibble(); } };
    

    gives me the virtualCallInConstructor message. I have to do this:

    struct Y: { virtual void wibble() = 0; virtual ~Y() {} };
    
    struct X final: public Y { void wibble() override final;  X() {} virtual ~X() { wibble(); } };
    

    to resolve it
    (cppcheck 2.8)

     

    Last edit: T Tanner 2022-07-02
  • Daniel Marjamäki

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

    For information instead of override final you should write final.

     
  • T Tanner

    T Tanner - 2022-07-05

    well, i thought i probably shouldn't be writing final at all, as the whole class as final!

    Thank you for raising a ticket, i shall follow it.

     

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.