Take this simple example.
struct Base {
// Base::Base() defined by the compiler
};
struct Derived: Base {
using Base::Base; // Should inherit Base::Base()
Derived(int value):
m_value(value)
{}
private:
int m_value; // If Base::Base() is invoked, it's default constructed
};
Derived t;
As far as I understand by reading cppreference, Derived
should inherit the default Base::Base()
constructor and the code above should happily compile.
Edit: my bad, the page I linked to tells exactly the opposite story. So it seems clang's got a regression.
However, all versions of gcc I've tried fail at it, complaining that Derived
has no default constructor, whilst clang does it just fine, but only since version 3.9.0; g++-7 segfaults, even 1.
You can see it by yourselves on godbolt.
So, who's at fault here? Clang for allowing it, or gcc (bar the segfault) for not allowing it?
1 Although it seems to do so only on godbolt, I cannot reproduce the segfault locally.