public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107402] New: Parenthesized aggregate initialization should not initialize references
@ 2022-10-25 17:44 ayzhao at google dot com
0 siblings, 0 replies; only message in thread
From: ayzhao at google dot com @ 2022-10-25 17:44 UTC (permalink / raw)
To: gcc-bugs
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-25 17:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 17:44 [Bug c++/107402] New: Parenthesized aggregate initialization should not initialize references ayzhao at google 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).