Skip to content

[intro.execution] How is the value computation that computes the result of an operator sequenced with the evaluation that initializes an object #968

Description

@xmh0511

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

Consider this example:

int main(){
  int a =1, b=2;
  int c = a + b;
}

The evaluation of the expression a+b, IIUC, will comprise these sub-evaluations:

  1. the value computation of a, let's call it A
  2. the value computation of b, let's call it B
  3. the value computation that computes the result of the operator +, let's call it S
  4. the evaluation that initializes the result object c, let's call it I

We do have a rule that specifies the sequence between the first three evaluations; that is, [intro.execution] p10

The value computations of the operands of an operator are sequenced before the value computation of the result of the operator.

However, we seem not to explicitly specify how S is sequenced with I. Intuitively, the computed result value should be stored into the context of the prvalue as its result as per [basic.lval] p5

The result of a prvalue is the value that the expression stores into its context;

It's reasonable that S should be sequenced before I; however, two evaluations will be unsequenced if there is no explicit specification.

Suggested Resolution:

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