I am using Coverity Prevent on a project to find errors.
It reports an error for this expression (The variable names are of course changed):
x=
(a>= b) ?
++x: 0;
The message is:
EVALUATION_ORDER defect: In "
x=(a>= b) ? ++x: 0;
", "x
" is written in "x
" (the assignment LHS) and written in "(a>= b) ? ++x: 0;
" but the order in which the side effects take place is undefined because there is no intervening sequence point. END OF MESSAGE
While I can understand that "x = x++
" is undefined, this one is a bit harder for me. Is this one a false positive or not?