Undefined behavior in c/c++: i++ + ++i vs ++i + i++ [duplicate]
This question already has an answer here: Why are these constructs using pre and post-increment undefined behavior? 14 answers Imagine that we have the code below: int i = 1; int j = i++ + ++i; I know that this is a Undefined Behavior, because before the semicolon, which is a sequence point, the value of i has been changed more than once. It means that the compiler may have two possibilities even if the precedence of operator plus is Left-to-Right: case 1) take the value of i++ --- value of i is 1 take the value of ++i --- value of i is 2 do the operator plus and assign the result which is 3