Skip to content

[expr.call] p9 The result of the function call is not clear #159

Closed
@xmh0511

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[expr.call] p9 says

The result of a function call is the result of the possibly-converted operand of the return statement ([stmt.return])

When the operand is an expression, the result of the operand(including converted one) is either an entity(the result of a glvalue) or a value(the result of a prvalue). What if the operand is a list initializer(i.e. braced-init-list)?

Moreover, there are some use of "the result of the function call" with different meanings in this document. [stmt.return] p5

The copy-initialization of the result of the call is sequenced before

In this context, "the result of the call" seems to refer to the returned reference or prvalue result object. As detailed in cplusplus/draft#4723.

In [dcl.init.ref] p5.4.1

The result of the call to the conversion function, as described for the non-reference copy-initialization, is then used to direct-initialize the reference.

However, in this context, we need an initializer expression to initialize the reference. As detailed in cplusplus/draft#5511, saying "the function call" rather than the result of the function call is more suitable here.

Then return to argue the meaning of "the result of the function call" itself, [expr.call] p14 says

A function call is an lvalue if the result type is an lvalue reference type or an rvalue reference to function type, an xvalue if the result type is an rvalue reference to object type, and a prvalue otherwise.

That means a function call is an expression. Then, according to [basic.lval] p5

The result of a glvalue is the entity denoted by the expression. The result of a prvalue is the value that the expression stores into its context;

From this perspective, the result of a function call is either an entity(i.e. the function call is a glvalue) or a value(i.e. the function call is a prvalue).

Hence, the definition of the result of a function call is ambiguous in this document, and there is some misuse of the wording in the document that cannot convey the intent clearly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions