This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54293] When a reference is bound to subobject of a temporary, lifetime of the temporary is not extended
- From: "crowl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Aug 2012 18:14:32 +0000
- Subject: [Bug c++/54293] When a reference is bound to subobject of a temporary, lifetime of the temporary is not extended
- Auto-submitted: auto-generated
- References: <bug-54293-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54293
crowl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |crowl at gcc dot gnu.org
--- Comment #5 from crowl at gcc dot gnu.org 2012-08-20 18:14:32 UTC ---
I think there is a compiler bug. The ruling text seems to be the
first bullet of 8.5.3/5 and its first sub-bullet:
- If the reference is an lvalue reference and the initializer
expression
- is an lvalue (but is not a bit-field), and "cv1 T1" is
reference-compatible with "cv2 T2," or
which matches the expression in the test case:
const int& ref_int = ValueHolder<int>().v;
The lifetime is extended by 12.2/5 where none of the exceptions
apply.