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

--- Comment #9 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2012-08-21 06:13:50 UTC ---
(In reply to comment #8)
> > I agree with your analysis, but would like to point out that there is change
> > planned to essentially this part of the wording due to 
> > 
> > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#616
> > 
> > Assuming it becomes accepted E1.E2 will become an xvalue in this case (SE
> > bullet 2 of the P/R)
> 
> Thanks for the info, it is interesting (although I can't see the relevance of
> this particular change to the issues it should solve, which are basically about
> using uninitialized objects).

Well, this addition *would* change the expected outcome. Because given the CWG
616 P/R the expression

ValueHolder<int>().v

becomes an xvalue (The special rule about class rvalues is no longer relevant
here), this means that the compiler shall *not* copy-initialize a temporary as
described in the very last bullet of 8.5.3/5.

In other words: In this case IsValid(&ref_int) will hold for the same reasons
as it holds for IsValid(&ref_obj).


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