[basic.lval] p5 value vs initialization
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
The result of a prvalue is the value that the expression stores into its context; a prvalue that has type cv void has no result. A prvalue whose result is the value V is sometimes said to have or name the value V.
In my mind, the value mentioned in the above rule is used to computes the value of an operand of an operator for the purpose. However, a prvalue is not only for this purpose but also perform initialization. What I want to say is it also store the initialization into its context, which is hinted in [conv.general] p3 and [conv.general] p6
An expression E can be implicitly converted to a type T if and only if the declaration T t=E; is well-formed, for some invented temporary variable t ([dcl.init]).
The effect of any implicit conversion is the same as performing the corresponding declaration and initialization and then using the temporary variable as the result of the conversion. The result is an lvalue if T is an lvalue reference type or an rvalue reference to function type ([dcl.ref]), an xvalue if T is an rvalue reference to object type, and a prvalue otherwise. The expression E is used as a glvalue if and only if the initialization uses it as a glvalue.
Consider an lvalue-to-rvalue conversion applies to a glvalue of class type, the result of that conversion is defined as
Otherwise, if T has a class type, the conversion copy-initializes the result object from the glvalue.
As per [conv.general] p3 and [conv.general] p6, this conversion as if performs that
T t = glvalue;
In this declaration, the copy-initialization is performed like that call a constructor with the argument glvalue to initialize the object. In this implicit conversion, the t is the result of the lvalue-to-rvalue conversion and it is prvalue, hence the modeled initialization will not actually perform except that there exists a result object. I think the value in the definition of the result of a prvalue should have a more general meaning.
The result of a prvalue is the value or initialization that the expression stores into its context; a prvalue that has type cv void has no result. A prvalue whose result is the value V is sometimes said to have or name the value V.
This modification may make the meaning of the prvalue in the new expression value category system be clearer. In the current, the concept of prvalue especially for class type is intricacy.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the [basic.lval] definition of a prvalue alongside [conv.general] p3 and p6, then compare their treatment of class-type lvalue-to-rvalue conversion and result objects. Done means determining whether the proposed wording about initialization accurately clarifies the value-category model and can be adopted without creating contradictions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100