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.
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.
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?
Aucun commentaire:
Enregistrer un commentaire