3

I already checked some other answers like:

Sequence point within assignment operators

or

Undefined behavior and sequence points

but I have still some doubt about the following part:

In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression.

It is not clear for me what is the "value computation of the assignment expression". Is it just (referring to the first link) "show" the number stored in the variable?

Community
  • 1
  • 1
andre3312
  • 147
  • 7
  • 1
    Imagine `h(f() = g());` Here `f()` and `g()` are evaluated first ("left and right operands"), then the assignment takes effect (i.e. the value of `f()` changes), and then the value of the assignment expression is computed. – Kerrek SB May 05 '16 at 09:22
  • Ok. I think (hope) is more clear. I thought that when your f() changes, THAT was the moment of the "value computation". But why is this last passage necessary? – andre3312 May 05 '16 at 09:29
  • @andre3312 "value computation" is the value of the expression (which may be viewed by another expression containing this expression); changes to objects are called *side-effects* – M.M May 05 '16 at 09:53
  • So the value computation of the assignment is just the returning the value for a possible another expression. Is it correct? For example in a = b + c the value computation of the assignment is returning the value of a. – andre3312 May 05 '16 at 10:13
  • `a = b = c + d;` I think the value of the assignment in the second assignement is the value of `b` in this example. – rozina May 05 '16 at 10:17
  • Ok. Now is more clear. – andre3312 May 05 '16 at 10:19
  • So would that imply that the expression `int x=a[a[1]=1]` would be specified as setting a[1] to 1 and yielding that value since the assignment would be sequenced before the outer array subscripting operator? – supercat Jun 20 '16 at 21:08

0 Answers0