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
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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 ` curdeius at gmail dot com
2021-10-14 7:14 ` pinskia at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: curdeius at gmail dot com @ 2021-10-14 7:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
--- Comment #1 from Curdeius Curdeius <curdeius at gmail dot com> ---
Also, the bug doesn't appear (or TBH, it's a different bug), when the unnamed
union contains a `content` data member. But it seems to be a bug then as well,
because it's not what is intended to be initialized.
Also, the bug doesn't appear without union.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-14 7:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
Ever confirmed|0 |1
Known to fail| |11.2.0
Last reconfirmed| |2021-10-14
Known to work| |10.3.0, 11.1.0
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=100489
Status|UNCONFIRMED |NEW
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just like PR 101767, so this is most likely caused by the patch which fixes PR
100489 so this is a regression in 10.4.0 also.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-14 7:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (2 preceding siblings ...)
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
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: curdeius at gmail dot com @ 2021-10-14 7:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
--- Comment #3 from Curdeius Curdeius <curdeius at gmail dot com> ---
For other users with this problem, a workaround is to use a named struct. So
here, it would look like:
```
typedef struct {
const void* content;
} put_t;
typedef struct {
union {
put_t put; // named struct
};
} op_t;
op_t f(const char* alias) {
return op_t{
.put =
put_t{ // named explicitly
.content = alias,
},
};
}
```
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (3 preceding siblings ...)
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
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 21:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |roland at gnu dot org
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 103290 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (4 preceding siblings ...)
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
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-11-16 22:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r12-954. (Bug 101405 also started with that rev.)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (5 preceding siblings ...)
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
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-11-19 17:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (6 preceding siblings ...)
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
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-20 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|ppalka at gcc dot gnu.org |unassigned at gcc dot gnu.org
Status|ASSIGNED |NEW
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (7 preceding siblings ...)
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
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-20 17:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=103337
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
PR103337 contains a related testcase which we reject with a similar error, and
interestingly that one isn't a regression.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (8 preceding siblings ...)
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
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-18 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [10/11/12 Regression] Data member not found in struct inside an unnamed union
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
` (9 preceding siblings ...)
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
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-21 20:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:24d51e749570dcb85bd43d3b528f58ad6141de26
commit r12-7741-g24d51e749570dcb85bd43d3b528f58ad6141de26
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 21 09:57:28 2022 -0400
c++: designated init and aggregate members [PR103337]
Our C++20 designated initializer handling was broken with members of class
type; we would find the relevant member and then try to find a member of
the member with the same name. Or we would sometimes ignore the designator
entirely. The former problem is fixed by the change to reshape_init_class,
the latter by the change to reshape_init_r.
PR c++/103337
PR c++/102740
PR c++/103299
PR c++/102538
gcc/cp/ChangeLog:
* decl.cc (reshape_init_class): Avoid looking for designator
after we found it.
(reshape_init_r): Keep looking for designator.
gcc/testsuite/ChangeLog:
* g++.dg/ext/flexary3.C: Remove one error.
* g++.dg/parse/pr43765.C: Likewise.
* g++.dg/cpp2a/desig22.C: New test.
* g++.dg/cpp2a/desig23.C: New test.
* g++.dg/cpp2a/desig24.C: New test.
* g++.dg/cpp2a/desig25.C: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [11 Regression] Data member not found in struct inside an unnamed union
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
` (10 preceding siblings ...)
2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
@ 2022-03-21 21:00 ` 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
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-21 21:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |11.3
Summary|[10/11/12 Regression] Data |[11 Regression] Data member
|member not found in struct |not found in struct inside
|inside an unnamed union |an unnamed union
Priority|P2 |P1
Known to work| |12.0
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed on trunk, never broken on 10 branch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [11 Regression] Data member not found in struct inside an unnamed union
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
` (11 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-22 5:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:2b2f575e6f27acc0c7ba6a3affc760bf2b96a84b
commit r11-9678-g2b2f575e6f27acc0c7ba6a3affc760bf2b96a84b
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 21 09:57:28 2022 -0400
c++: designated init and aggregate members [PR103337]
Our C++20 designated initializer handling was broken with members of class
type; we would find the relevant member and then try to find a member of
the member with the same name. Or we would sometimes ignore the designator
entirely. The former problem is fixed by the change to reshape_init_class,
the latter by the change to reshape_init_r.
PR c++/103337
PR c++/102740
PR c++/103299
PR c++/102538
gcc/cp/ChangeLog:
* decl.c (reshape_init_class): Avoid looking for designator
after we found it.
(reshape_init_r): Keep looking for designator.
gcc/testsuite/ChangeLog:
* g++.dg/ext/flexary3.C: Remove one error.
* g++.dg/parse/pr43765.C: Likewise.
* g++.dg/cpp2a/desig22.C: New test.
* g++.dg/cpp2a/desig23.C: New test.
* g++.dg/cpp2a/desig24.C: New test.
* g++.dg/cpp2a/desig25.C: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/102740] [11 Regression] Data member not found in struct inside an unnamed union
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
` (12 preceding siblings ...)
2022-03-22 5:18 ` cvs-commit at gcc dot gnu.org
@ 2022-03-26 23:28 ` jason at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-26 23:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102740
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixend for 11.3 as well.
^ 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).