This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54293] When a reference is bound to subobject of a temporary, lifetime of the temporary is not extended


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]