[Bug c++/116012] New: gcc allows calling to implicitly-deleted default constructor in virtual inheritance with inherited constructor by using-declaration
rush102333 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Jul 20 09:53:28 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116012
Bug ID: 116012
Summary: gcc allows calling to implicitly-deleted default
constructor in virtual inheritance with inherited
constructor by using-declaration
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rush102333 at gmail dot com
Target Milestone: ---
The following code is accepted by gcc but rejected by clang, MSVC and EDG:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct base {
base(int) {}
virtual void foo() = 0;
virtual ~base() {}
};
struct left : virtual base {
public:
using base:: base;
};
struct derived : left{
virtual void foo() override {}
derived() : base(10) {}
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because struct "left" inherits the constructors of its base class "base", it
has had a valid user-defined ctor. The defaulted ctor should then be deleted,
so the constructor's declaration of struct "derived" should be invalid.
Clang gives the following error message:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:5: error: call to implicitly-deleted default constructor of 'left'
15 | derived() : base(10) {}
| ^
1 error generated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please check https://godbolt.org/z/znbY1E4ro
More information about the Gcc-bugs
mailing list