The resolution of issues 616 and 1213, making the result of a member access or subscript expression applied to a prvalue an xvalue, means that binding a reference to such a subobject of a temporary does not extend the temporary's lifetime.
On 2016–03–14, at 8:10 AM, Columbo <r....@gmx.net> wrote:The resolution of issues 616 and 1213, making the result of a member access or subscript expression applied to a prvalue an xvalue, means that binding a reference to such a subobject of a temporary does not extend the temporary's lifetime.Why is that? Is a reference only said to "bind to a temporary" if its initializer is a prvalue? Or can a temporary (or its subobject) only be designated as such if done via a prvalue? The latter is vaguely implied by the definition of rvalues in [basic.lval]/(1.4).
Yes, this was one of the reasons why I suggested the notion of temporary expression. In this case the member access expression would be a temporary expression, with the temporary object of the object expression as its temporary object. T().a.b for instance (for nonreference members) has a single temporary object and three temporary expressions T(), T().a and T().a.b . Notice that the latter two expressions refer to non temporary objects. Currently the Standard has an ugly workaround special case for that (without checking now, I do believe however that the special case would still work if the member access expression is made an xvalue).
On 2016–03–14, at 3:40 PM, 'Johannes Schaub' via ISO C++ Standard - Discussion <std-dis...@isocpp.org> wrote:Yes, this was one of the reasons why I suggested the notion of temporary expression. In this case the member access expression would be a temporary expression, with the temporary object of the object expression as its temporary object.
Thanks, I will look into your proposals when I get some time. However, the purpose of the temporary expression notion is not to have an 1:1 mapping with temporary objects. Its more of a n:1 mapping from expressions to temporary objects. For a symbolic execution of a conditional expression, you can also have a set of possible temporary objects belonging to temporary conditional expression. This is nothing special about temporary expressions though and this fact doesn't need to be modeled afaics.