public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xmh970252187 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/109768] New: Construct an anonymous union variable with a variant member that has deleted the destructor should be ill-formed
Date: Mon, 08 May 2023 09:11:28 +0000	[thread overview]
Message-ID: <bug-109768-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109768
           Summary: Construct an anonymous union variable with a variant
                    member that has deleted the destructor should be
                    ill-formed
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

#include <iostream>
struct B{
    B() = default;
    ~B() = delete;
};

int main(){
  union {B b;};
}

Both [class.dtor] p7 
> A defaulted destructor for a class X is defined as deleted if: 
>> X is a union-like class that has a variant member with a non-trivial destructor,

and [class.ctor.class.default.ctor] p2
> A defaulted default constructor for class X is defined as deleted if: 
>> - any potentially constructed subobject has a type with a destructor that is deleted or inaccessible from the defaulted default constructor.

The anonymous union object just has a deleted constructor and destructor. GCC
accepts this example while Clang rejects it.

             reply	other threads:[~2023-05-08  9:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  9:11 xmh970252187 at gmail dot com [this message]
2023-05-08 17:16 ` [Bug c++/109768] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109768-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).