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

            Bug ID: 66644
           Summary: Rejects C++11 in-class anonymous union members
                    initialization
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bisqwit at iki dot fi
  Target Milestone: ---

Accepted by GCC:

    struct test  
    {   union  
        {
            struct { char a=0, b; };
            char buffer[16];
    };  };

NOT accepted by GCC (multiple fields in union 'test::<anonymous union>'
initialized):

    struct test  
    {   union  
        {
            struct { char a=0, b=0; };
            char buffer[16];
    };  };

Still accepted by GCC:

    struct test
    {   union
        {
            struct { char a, b; } test2{0,
            char buffer[16];
    };  };

I think there's a compiler bug here. It should not complain about initializing
multiple fields in a struct that is nested inside the union, because this does
not comprise a conflict.

Tested on GCC versions 4.7.4, 4.8.4, 4.9.2, and 5.1.1.

Reply via email to