Description
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 lvalue
s.
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 xvaluestatic_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 nevercannot 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.