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

            Bug ID: 103290
           Summary: gcc 11 regression with C++ designated initializers,
                    unions, anonymous struct
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland at gnu dot org
  Target Milestone: ---

```
struct S {                                                                      
  union {                                                                       
    struct {                                                                    
      unsigned short x;                                                         
    } s;                                                                        
  };                                                                            
};                                                                              

S foo() {                                                                       
  S x = {.s = {.x = 1}};                                                        
  return x;                                                                     
}
```

with g++

produces error: 'S::<unnamed union>' has no non-static data member named 'x'

This is a regression from GCC 10.  The same code compiled as C still works.

Reproduced on trunk at 4cdf7db9a39d18bd536d816a5751d4d3cf23808b and on 11
branch at b52e2254b30445f3cd667ae0f0d99b183394e37b.

Reply via email to