public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "janschultke at googlemail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list Date: Tue, 14 May 2024 09:38:03 +0000 [thread overview] Message-ID: <bug-115085-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2024-05-14 9:38 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-14 9:38 janschultke at googlemail dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-115085-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).