Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[intro.execution] Is i = i++ + 1 really well-formed? #2965

Closed
cpplearner opened this issue Jul 11, 2019 · 1 comment
Closed

[intro.execution] Is i = i++ + 1 really well-formed? #2965

cpplearner opened this issue Jul 11, 2019 · 1 comment

Comments

@cpplearner
Copy link
Contributor

cpplearner commented Jul 11, 2019

#1020, as a fix to #953, changed the example in [intro.execution]/10 so it now contains:

  i = i++ + 1;                  // the value of i is incremented

I suspect that this change is not correct.

According to [expr.ass], the following steps take place in order:

  1. the value computation of rhs (i++ + 1)
  2. the value computation of lhs (i)
  3. the assignment to i
  4. the value computation of the assignment expression

But it appears to me that [expr.ass] doesn't specify how the side effect of i++ (i.e. the modification to i) happens relative to step 3.

Also, P0145R3 mentions "the current proposal does not suggest any particular modification to the sequencing of unary expressions", which seems to suggest that i++ is still unsequenced relative to the assignment, thus the expression has UB under the post-P0145R3 rules just like under the old rules.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Jul 11, 2019
@cpplearner
Copy link
Contributor Author

Sorry, it seems that I misunderstood. [expr.ass] says "The right operand is sequenced before the left operand." which actually means the side effect of i++ is sequenced before step 2.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants