public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109768] New: Construct an anonymous union variable with a variant member that has deleted the destructor should be ill-formed
@ 2023-05-08  9:11 xmh970252187 at gmail dot com
  2023-05-08 17:16 ` [Bug c++/109768] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: xmh970252187 at gmail dot com @ 2023-05-08  9:11 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/109768] Construct an anonymous union variable with a variant member that has deleted the destructor should be ill-formed
  2023-05-08  9:11 [Bug c++/109768] New: Construct an anonymous union variable with a variant member that has deleted the destructor should be ill-formed xmh970252187 at gmail dot com
@ 2023-05-08 17:16 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-05-08
     Ever confirmed|0                           |1
      Known to work|4.5.3                       |

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, it is only an anonymous union that is an issue here ...

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

end of thread, other threads:[~2023-05-08 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08  9:11 [Bug c++/109768] New: Construct an anonymous union variable with a variant member that has deleted the destructor should be ill-formed xmh970252187 at gmail dot com
2023-05-08 17:16 ` [Bug c++/109768] " 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).