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

            Bug ID: 114129
           Summary: Inaccurate error message
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Theodore.Papadopoulo at inria dot fr
  Target Milestone: ---

Given the code below

struct A {
    virtual void f() { }
};

struct B: public A {
    void f() override() { }
};

The g++ compiler gives the following error:
-> g++ -O3 test.cpp 
test.cpp:6:5: error: ‘f’ declared as function returning a function
    6 |     void f() override() { }
      |     ^~~~

Technically, it should be 'override' declared as function returning a function.
or even maybe that override is a reserved name and cannot be used as a function
name...

Yet this is much better than clang:
-> clang++ -O3 test.cpp
test.cpp:6:22: error: expected ';' at end of declaration list
    6 |     void f() override() { }
      |                      ^
      |                      ;
1 error generated.

Reply via email to