public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ayzhao at google dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107402] New: Parenthesized aggregate initialization should not initialize references Date: Tue, 25 Oct 2022 17:44:00 +0000 [thread overview] Message-ID: <bug-107402-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107402 Bug ID: 107402 Summary: Parenthesized aggregate initialization should not initialize references Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ayzhao at google dot com Target Milestone: --- The implementation of P0960R3 in <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91363> and <https://gcc.gnu.org/legacy-ml/gcc-patches/2019-10/msg01578.html> allowed for initialization of references by creating and initializing a temporary of the referered type. Therefore, statements such as const MyStruct& m(1, 1); int (&&rr)[](1, 2, 3, 4); are accepted by GCC: <https://godbolt.org/z/WvEx6xE19> A close reading of the C++ standard suggests that these expressions are not allowed. Reference initialization via a temporary is described in <http://eel.is/c++draft/dcl.init.ref#5.4>, and that only permits conversion by constructor or conversion function (if the source or destination is of class type) or implicit conversion, not arbitrary direct-initialization conversions (which would include aggregate initialization)
reply other threads:[~2022-10-25 17:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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-107402-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).