Richard said:
That is totally platform dependant and therefore ... you know.
Yes, exactly - that's what I was pointing out. To put it more formally,
I was making it clear that the order of evaluation is unspecified, and
I used a completely hypothetical but easily understood asm-like
pseudocode to make clear one possible (albeit weird) order of
evaluation that runs counter to our intuition. In your rush to post,
you seem to have missed the point of my reply (as ever).
As far as C goes, he was right. The ++ is applied to "i" after the
value of I is evaluated and handed to the return statement.
You also appear to have missed reading it. Your claim here is simply
false. The point at which the increment happens is unspecified.
There is no need whatsoever to obfuscate this.
Nor did I do so. But there is certainly no need to give an incorrect
explanation such as yours.
To the OP. You code does not exhibit "UB" until overflow.
I already pointed this out, some time ago. In your rush to post, you
seem to have missed this. Did you not claim that you do not bother to
post answers to questions that have already been answered?
And then its platform specific I believe.
You mean you don't know? I suggest you find out, by reading and
understanding instead of looking for any pretext, no matter how
spurious, to criticise those who *do* know.
But I'll tell you. The behaviour on overflow is undefined. The Standard
does *not* require that undefined behaviour must be platform-specific.
For all it cares, the behaviour could depend on the phase of the moon,
or some equally bizarre platform-independent phenomenon.