https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105701
Bug ID: 105701
Summary: Warn about unused initializer for virtual base
Product: gcc
Version: 12.1.1
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
struct Base
{
Base() { }
Base(int) { }
virtual void f() = 0;
};
struct Abstract : virtual Base
{
Abstract(int i) : Base(i) { }
};
struct Concrete : Abstract
{
Concrete() : Abstract(1) { }
void f() override { }
};
A user on IRC suggested we should warn about the Base(i) initializer in the
Abstract(int) constructor. That class can never be constructed, so it can never
initialize the virtual base.
IIUC that is true even if the derived class does 'using Abstract::Abstract;' so
I don't think there's any way for that Base(i) to ever be used.