public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106150] New: Incorrect error for defaulted anonymous union member
@ 2022-06-30 18:45 jens.maurer at gmx dot net
  2022-07-01  1:40 ` [Bug c++/106150] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jens.maurer at gmx dot net @ 2022-06-30 18:45 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2022-07-22  7:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 18:45 [Bug c++/106150] New: Incorrect error for defaulted anonymous union member jens.maurer at gmx dot net
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

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).