Reputation: 139
I know that x++ refers to post increment. It first uses the original value and then resorts to the incremented value.
But when does that actually happen? Does it happen when the next immediate line in code is executed? Does it happen when original value is returned once?
Upvotes: 2
Views: 70
Reputation: 108978
It happens between sequence points.
Other than that, it's unspecified when it happens.
Imagine this
x = y = z = 42
; // sequence point A
n = x++ + y++ + z++
; // sequence point B
At seq. point A x, y, and z are all 42; at sequence point B they are all 43. For all you care, the compiler could emit code to update all 3 variables at the same time.
// pseudo code
n = 126;
[vector increment][x,y,z];
//n = 126;
Upvotes: 3