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: "jpalecek at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Aug 2012 07:51:55 +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
--- Comment #10 from JiÅÃ PaleÄek <jpalecek at web dot de> 2012-08-21 07:51:55 UTC ---
(In reply to comment #9)
> (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).
That is true, and I didn't object that. I rather didn't understand how is that
particular change related to solving issues 616, 129, 240 and some others
mentioned there.