public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116012] New: gcc allows calling to implicitly-deleted default constructor in virtual inheritance with inherited constructor by using-declaration
@ 2024-07-20  9:53 rush102333 at gmail dot com
  2024-07-20 20:15 ` [Bug c++/116012] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: rush102333 at gmail dot com @ 2024-07-20  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/116012] gcc allows calling to implicitly-deleted default constructor in virtual inheritance with inherited constructor by using-declaration
  2024-07-20  9:53 [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
@ 2024-07-20 20:15 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-20 20:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116012

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-07-20

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-20 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-20  9:53 [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
2024-07-20 20:15 ` [Bug c++/116012] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).