In cases like:
int q = 3;
++q * ++q
It will be an undefined behaviour in C.
However, what about the following scenarios?
++q * q
++q * q++
Note: I am not asking what is the definition of undefined behaviour
.
My question is: What are the specific rules to help us to determine whether an expression will be an undefined behaviour especially when pre-increment is involved?
I found this piece of information online:
The behavior of modifying the value of an object through the evaluation of an expression more than once between sequence points is undefined. The behavior of using the value of an object in one expression when its being modified in another expression without an intervening sequence point is also undefined.
Does it mean that if the same variable in a single expression is changed more than once, it will be an undefined behaviour?