https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Bug ID: 102740 Summary: [11.2/12 Regression] Data member not found in struct inside an unnamed union Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: curdeius at gmail dot com Target Milestone: --- Reproduce on godbolt: https://godbolt.org/z/3frPbPj35. This snippet of code works ok on gcc 11.1, but fails to compile on gcc 11.2 and trunk (12). ``` typedef struct { union { struct { const void* content; } put; }; } op_t; op_t f(const char* alias) { return op_t{ .put = { .content = alias, }, }; } ``` The error message (compiled with `-std=c++20` but the standard version seems irrelevant): ``` <source>: In function 'op_t f(const char*)': <source>:15:5: error: 'op_t::<unnamed union>' has no non-static data member named 'content' 15 | }; | ^ Compiler returned: 1 ``` >From the error message, it seems that the compiler searches for `content` data member inside the unnamed union and not in the unnamed `put` struct.