[Bug c++/84581] New: GCC expects "override" keyword in incorrect grammar position
myriachan at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Feb 27 00:45:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84581
Bug ID: 84581
Summary: GCC expects "override" keyword in incorrect grammar
position
Product: gcc
Version: 7.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: myriachan at gmail dot com
Target Milestone: ---
GCC expects the "override" keyword in an incorrect position in the C++ grammar:
#define MEOW 256
struct Base {
virtual const char (&GetBuffer() const)[MEOW] = 0;
};
struct Derived : public Base {
// GCC requires this incorrect syntax...
virtual const char (&GetBuffer() const override)[MEOW];
// ...but the below is the correct syntax, which GCC rejects.
virtual const char (&GetBuffer() const)[MEOW] override;
};
In the C++ Standard, "override" is a virt-specifier in a virt-specifier-seq.
virt-specifier-seq optionally goes after the declarator. After the optional
virt-specifier-seq goes the optional pure-specifier.
Possibly related bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64794 (I
don't know whether "-> override" is sensible; just linking this in case that
bug's reporter is correct.)
More information about the Gcc-bugs
mailing list