Skip to content

[dcl.fct.def.coroutine] p13 A xvalue with its initial type "lvalue reference to cv T" #43

Open
@xmh0511

Description

@xmh0511

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

[dcl.fct.def.coroutine] p13 says

For a parameter of type cv T, the copy is a variable of type cv T with automatic storage duration that is direct-initialized from an xvalue of type T referring to the parameter.

How is such an xvalue produced if T is "lvalue reference to cv U"? Even though we didn't explicitly specify whether an expression of type "lvalue reference to object type" can be an xvalue or not, anyway, from the convention and all rules defined in [expr], there is no such an xvalue. Basically, almost all of the expressions with "lvalue reference to object type" are lvalues.

Suggested resolution:

For a parameter of type cv T, the copy is a variable of type cv T with automatic storage duration that is direct-initialized as defined in the following:

  • Assume that an id-expression P names the parameter:
  • If T is "reference to cv2 U", is direct-initialized from the xvalue static_cast<cv2 U&&>(P),
  • otherwise, is direct-initialized from the xvalue const_cast<T&&>(P)

This can make xvalue clear defined in this rule. Change [dcl.fct.def.coroutine.note] 2 to

An original parameter object is never cannot be a const or volatile object ([basic.type.qualifier]).

An object denoted by an xvalue of cv-unqualified that type remains no change if it is a const or volatile object. "is never" sounds like this property would be changed after an xvalue denoting the object. The intent is that the object denoted by the xvalue should be a non-const non-volatile object in order to make the program be well-formed if any modification will be done through the xvalue.

This issue is also mentioned in cplusplus/draft#4870, but that issue did not clearly expound the thought.

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