after evaluating the expression for the if condition"? No, you can't make claims like that. No one knows when post-increment is physically applied within this expression. And it doesn't really matter. The only thing that matters is that the subscripting is guaranteed to use the original ("old", "before increment") value of `CntrlPrefixIndex`.
Exactly so.
The only guarantee we have is that the side effects are complete at each sequence point, but there are no requirements on the side effects ordering and place while evaluating each full expression.
Post increment is a side effect, and there is a sequence point between the end of the if control (full) expression and a following full expression.
(C11, Annex 3 - sequence points).
The post-increment is applied after evaluating the expression for the if condition *BEFORE* executing the block controlled by the if statement.
If you don't want the increment to happen on the last pass, you need to move it out of the condition and into a new else block.
Forgetting the "after evaluating" that's been already discussed, and spraining my nitpick ligament
, I would object that the standard does not really force the side effect to complete before the break is executed.
Sequence points are only defined in terms of evaluations and break is not an expression, albeit it's guaranteed that there'll be a SP before the result of the side effect (++) can be used in any way.
A smart compiler might notice that all program paths will somehow yield an incremented CntrlPrefixIndex and place its actual increment in a more optimal position.