public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jens.maurer at gmx dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106150] New: Incorrect error for defaulted anonymous union member
Date: Thu, 30 Jun 2022 18:45:25 +0000	[thread overview]
Message-ID: <bug-106150-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106150
           Summary: Incorrect error for defaulted anonymous union member
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jens.maurer at gmx dot net
  Target Milestone: ---

The following is valid, but yields an error with gcc 12.1:

struct A {
   A() { }
};

struct V {
   V() { };
   ~V() { }
};


struct S {
   S();
   ~S() {}

   union {
     A a = {};
     V v;
   };
};

S::S() = default;


x.cc:22:1: note: ‘S::S()’ is implicitly deleted because the default definition
would be ill-formed:
   22 | S::S() = default;
      | ^
x.cc:18:8: error: union member ‘S::<unnamed union>::v’ with non-trivial
‘V::V()’
   18 |      V v;
      |        ^


Replacing "= default" with "{}" makes the error go away.

None of the items in [class.default.ctor] p2 applies, in particular p2.2 does
not apply because S::a has a default member initializer.

             reply	other threads:[~2022-06-30 18:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 18:45 jens.maurer at gmx dot net [this message]
2022-07-01  1:40 ` [Bug c++/106150] " pinskia at gcc dot gnu.org
2022-07-01  1:43 ` pinskia at gcc dot gnu.org
2022-07-01  1:56 ` pinskia at gcc dot gnu.org
2022-07-01  1:58 ` [Bug c++/106150] [DR 2084] union with more than one variant and non-trivial constructor is not accepted pinskia at gcc dot gnu.org
2022-07-01  2:05 ` pinskia at gcc dot gnu.org
2022-07-01  6:20 ` jens.maurer at gmx dot net
2022-07-20 21:31 ` redi at gcc dot gnu.org
2022-07-22  7:23 ` redi 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-106150-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).