C++ standards: is there a result object?

Viewed 334
int foo() { return 0; }
int x = foo() + 1;

This says the foo() function call expression has no result object:

a non-discarded prvalue that is used to compute the value of an operand of a built-in operator or a prvalue that has type cv void has no result object

I read this as follows: (a non-discarded prvalue that is used to compute the value of an operand of a built-in operator) or (a prvalue that has type cv void) has no result object. The first case is ours.

On the other hand, that talks about the result object of the function call:

the return statement initializes the glvalue result or prvalue result object of the (explicit or implicit) function call by copy-initialization from the operand

I read this as follows: the return statement initializes the (glvalue result) or (prvalue result object) of the ... function call by copy-initialization from the operand. The second case is ours.

So what exactly does return 0; initialize? Perhaps, it is meant that the temporary from here is being initialized?

1 Answers

I believe that's a defect. The correction can be as follows:

the return statement initializes the glvalue result or prvalue result of the (explicit or implicit) function call by copy-initialization from the operand

A prvalue function call can have no result object. It always has a result if the return type is not cv void.

Related