https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125447
Bug ID: 125447
Summary: GCC accepts invalid override in a class template with
non-dependent bases
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: qurong at ios dot ac.cn
Target Milestone: ---
GCC accepts the following program:
struct A {
virtual void fa() = 0;
};
struct B {
virtual void fb() = 0;
};
template<class T>
struct Foo : A, B {
void ga() override {}
void gb() override {}
};
Foo<int> x;
ga does not override A::fa, and gb does not override B::fb, so the program
should be rejected.
For comparison, Clang rejects it with:
error: 'ga' marked 'override' but does not override any member functions
error: 'gb' marked 'override' but does not override any member functions
Expected behavior
GCC should reject the program because both override specifiers are invalid.