Re: [PATCH 0/2] Make chained function calls in expressions work

Siva Chandra
2014-10-21T21:07:04Z

On Tue, Oct 21, 2014 at 1:30 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Tue, Oct 21, 2014 at 4:15 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>> I was not refering to the ABI, but the C++ standard semantics that
>> define what happen when you pass an *object* as argument to a function
>> that expects a *reference* parameter. See e.g.:
>> http://en.cppreference.com/w/cpp/language/reference_initialization
>>
>> References are initialized in the following situations:
>> [...]
>> 3) In a function call expression, when the function parameter
>> has reference type
>> [...]
>> The effects of reference initialization are:
>> [...]
>> if the reference is [...] lvalue reference to const:
>> [...]
>> a temporary of type T is constructed and copy-initialized from
>> object. The reference is then bound to this temporary
>
> I do not think applies in general for const references. IIUC, it
> applies to prvalues/literals [section 12.2 in the C++ std]. For all
> other kind of values, the two cases above this point should be
> applied.

I should have said prvalues of non-class type.

> Function arguments could be xvalues. IIUC, temporaries are created
> only for prvalues. You can point me to the appropriate section in the
> C++ standard if I am wrong.

Same here.