public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102740] New: [11.2/12 Regression] Data member not found in struct inside an unnamed union
@ 2021-10-14  7:05 curdeius at gmail dot com
  2021-10-14  7:13 ` [Bug c++/102740] [10/11/12 " curdeius at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: curdeius at gmail dot com @ 2021-10-14  7:05 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-03-26 23:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14  7:05 [Bug c++/102740] New: [11.2/12 Regression] Data member not found in struct inside an unnamed union curdeius at gmail dot com
2021-10-14  7:13 ` [Bug c++/102740] [10/11/12 " curdeius at gmail dot com
2021-10-14  7:14 ` pinskia at gcc dot gnu.org
2021-10-14  7:16 ` rguenth at gcc dot gnu.org
2021-10-14  7:56 ` curdeius at gmail dot com
2021-11-16 21:57 ` pinskia at gcc dot gnu.org
2021-11-16 22:21 ` mpolacek at gcc dot gnu.org
2021-11-19 17:18 ` ppalka at gcc dot gnu.org
2022-01-20 17:33 ` ppalka at gcc dot gnu.org
2022-01-20 17:42 ` ppalka at gcc dot gnu.org
2022-03-18 19:15 ` jason at gcc dot gnu.org
2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
2022-03-21 21:00 ` [Bug c++/102740] [11 " jason at gcc dot gnu.org
2022-03-22  5:18 ` cvs-commit at gcc dot gnu.org
2022-03-26 23:28 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).