cplusplus / cplusplus/draft

[intro.execution] p7 value computation vs. prvalue

Open
#5,477 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[intro.execution] p7 says

Evaluation of an expression (or a subexpression) in general includes both value computations (including determining the identity of an object for glvalue evaluation and fetching a value previously assigned to an object for prvalue evaluation) and initiation of side effects.

Consider the sentence in the parenthesis

determining the identity of an object for glvalue evaluation

This is exact the definition of glvalue per [basic.lval] p 1.1

A glvalue is an expression whose evaluation determines the identity of an object or function.

It could be understood that the evaluation of a glvalue is a kind of value computation. However, the emphasized part is a bit strange:

fetching a value previously assigned to an object

This sounds like the duty of the lvalue-to-rvalue conversion. What if an expression itself is a prvalue(e.g. 0 + int{1};)? Shall we just say

fetching the value of a prvalue for prvalue evaluation(i.e. computes the value of an operand of an operator)

This is one function of the evaluation of prvalue

A prvalue is an expression whose evaluation computes the value of an operand of an operator, as specified by the context in which it appears

It is not sure whether the initialization of the result object of a prvalue takes account to be the value computation? After all, we just define the side effect as

Reading an object designated by a volatile glvalue ([basic.lval]), modifying an object, calling a library I/O function, or calling a function that does any of those operations are all side effects

We define "modifying an object" with the cross-reference to ([expr.ass], [expr.post.incr], [expr.pre.incr]), in [dcl.type.cv]

Any attempt to modify ([expr.ass], [expr.post.incr], [expr.pre.incr]) a const object

however, they are not about initialization.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [intro.execution] p7 and compare its value-computation wording with the cited [basic.lval] definitions of glvalues, prvalues, side effects, and modification. Trace how initialization and prvalue evaluation are described in the surrounding standard text. Done means the draft clearly distinguishes value computation, object initialization, and side effects without creating conflicting definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.