public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
@ 2024-05-14 9:38 janschultke at googlemail dot com
2024-05-14 9:41 ` [Bug c++/115085] " janschultke at googlemail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: janschultke at googlemail dot com @ 2024-05-14 9:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
Bug ID: 115085
Summary: Variable unqualified-id is falsely treated as rvalue
when appearing in braced-init-list
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: janschultke at googlemail dot com
Target Milestone: ---
> int a{}, b = decltype((a)){a};
GCC falsely rejects this (https://godbolt.org/z/a6c4h8Mhv).
If you're having trouble reading this, it also rejects:
> using T = int&;
> int a{}, b = T{a};
Splitting this into multiple lines is also not relevant. The error is:
> <source>:3:17: error: cannot bind non-const lvalue reference of type 'T' {aka 'int&'} to an rvalue of type 'int'
> 3 | int a{}, b = T{a};
> | ^
There is no apparent reason why should be an rvalue in this context. It is not
move-eligible within the initializer of a variable.
My guess is something something aggregate initialization doing
copy-initialization for each initializer and then getting a prvalue out of
that. Dunno, it's quite weird.
See https://stackoverflow.com/a/78477064/5740428 for a more in-depth
explanation of the relevant wording.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/115085] Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
@ 2024-05-14 9:41 ` janschultke at googlemail dot com
2024-05-14 9:50 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janschultke at googlemail dot com @ 2024-05-14 9:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
--- Comment #1 from Jan Schultke <janschultke at googlemail dot com> ---
Another user suggested that this is caused by falsely performing temporary
materialization.
This would make a an xvalue, which would also make the reference binding fail.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/115085] Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
2024-05-14 9:41 ` [Bug c++/115085] " janschultke at googlemail dot com
@ 2024-05-14 9:50 ` pinskia at gcc dot gnu.org
2024-05-14 9:58 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-14 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think there is a dup of this bug already filed ...
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/115085] Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
2024-05-14 9:41 ` [Bug c++/115085] " janschultke at googlemail dot com
2024-05-14 9:50 ` pinskia at gcc dot gnu.org
@ 2024-05-14 9:58 ` pinskia at gcc dot gnu.org
2024-05-14 10:24 ` janschultke at googlemail dot com
2024-05-14 10:53 ` jlame646 at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-14 9:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
See https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1521 also.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/115085] Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
` (2 preceding siblings ...)
2024-05-14 9:58 ` pinskia at gcc dot gnu.org
@ 2024-05-14 10:24 ` janschultke at googlemail dot com
2024-05-14 10:53 ` jlame646 at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: janschultke at googlemail dot com @ 2024-05-14 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
--- Comment #4 from Jan Schultke <janschultke at googlemail dot com> ---
https://github.com/cplusplus/CWG/issues/536
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/115085] Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
` (3 preceding siblings ...)
2024-05-14 10:24 ` janschultke at googlemail dot com
@ 2024-05-14 10:53 ` jlame646 at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: jlame646 at gmail dot com @ 2024-05-14 10:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
Jason Liam <jlame646 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jlame646 at gmail dot com
--- Comment #5 from Jason Liam <jlame646 at gmail dot com> ---
Maybe related bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64892
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78209
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-14 10:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 9:38 [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list janschultke at googlemail dot com
2024-05-14 9:41 ` [Bug c++/115085] " janschultke at googlemail dot com
2024-05-14 9:50 ` pinskia at gcc dot gnu.org
2024-05-14 9:58 ` pinskia at gcc dot gnu.org
2024-05-14 10:24 ` janschultke at googlemail dot com
2024-05-14 10:53 ` jlame646 at gmail dot com
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).