[Bug c++/98864] New: Warning for unnecessary final keyword

drepper.fsp+rhbz at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 28 13:14:36 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98864

            Bug ID: 98864
           Summary: Warning for unnecessary final keyword
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com
  Target Milestone: ---

Compile the following code:

struct foo {
  virtual void f();
};

struct bar final : foo {
  void f() final override;
};

It is correct and should compile but the function bar::f is annotated with
'final' even though the entire class is also annotated with 'final'.  This adds
nothing and might be an indication of misunderstanding or leftovers from
previous versions of the code.

Perhaps a warning can be added to point out the issue.


More information about the Gcc-bugs mailing list