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

            Bug ID: 86001
           Summary: explicit default constructor not allowed in anonymous
                    aggregate
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xavierb at gmail dot com
  Target Milestone: ---

Hello,

In this example:

union Union {
    int val;

    Union() = default;
    Union(int _v) : val(_v) {}
};

struct StructA {
    Union u;
};

struct StructB {
    struct {
        Union u;
    } s;
};

struct StructC {
    struct {
        Union u;
    };
};

GCC (6,7,8 and 9) accept StructA and StructB.
but not StructC:

   error: member 'Union StructC::<unnamed struct>::u' with constructor not
allowed in anonymous aggregate

Maybe it's not valid c++ for some reason? But it compiles fine with clang,
msvc, icc.

Reply via email to