https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91159
Bug ID: 91159 Summary: Compilation error on explicitly defaulting default constructor of abstract class with virtual base class Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: krzyk240 at gmail dot com Target Milestone: --- Consider the code below: ``` class Base { public: Base(int) {} virtual void foo() = 0; virtual ~Base() = default; }; class A : virtual public Base { public: A() = default; // Works with this line commented out }; class B : public A { public: B() : Base(0) {} void foo() override {} }; int main() { B b; } ``` It does not compile with GCC but compiles with Clang without problems. However, that is a minor issue. The core issue is that with the line `A() = default;` commented out, this code compiles fine on GCC. So, the question is: Should be there such difference between implicitly declared default constructor and explicitly defaulted default constructor? If such code is anyhow wrong, what should be the correct way to write it? As I understand, there is no point in making constructor of class A that initializes the class Base. That is because Base class is virtually inherited and class A is abstract. That means that A cannot be constructed directly and since the most derivative class has to directly call the virtual base class constructor, class A will never construct Base directly.