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

            Bug ID: 69131
           Summary: [4.9/5/6 Regression] default constructor of union
                    incorrectly deleted
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

From http://stackoverflow.com/q/34581372/2756719, repro:

struct X
{
    ~X() {}
};

union U
{
    X x;
    ~U() {}
};

U u;

The default constructor of `X` is trivial. Nothing in [class.ctor]/4 applies,
so U's default constructor shouldn't be deleted. However, GCC 4.9 and later
rejects this code with:

prog.cc:12:3: error: use of deleted function 'U::U()'
 U u;
   ^

prog.cc:6:7: note: 'U::U()' is implicitly deleted because the default
definition would be ill-formed:
 union U
       ^

GCC 4.6-4.8 and all versions of Clang I tested accept this code.

Reply via email to