My favourite description of undefined behaviour. The poster is corrected later on in the thread about whether the specific operation discussed would invoke undefined behaviour, but the description of what happens when undefined behaviour occurs is gold:<p><a href="https://groups.google.com/g/comp.lang.c/c/ZE2B2UorTtM/m/1ROv8gTwuEAJ" rel="nofollow">https://groups.google.com/g/comp.lang.c/c/ZE2B2UorTtM/m/1ROv...</a><p>Joona I Palaste, 2001-01-19, comp.lang.c<p><pre><code> This isn't about the post-increment operator, this is about the order
of evaluation of the operands.
Since you're modifying the value of i twice without a sequence point
in between, either of the two results are exactly as much "expected".
Also, equally "expected" behaviour includes incrementing every
variable in the array, flipping all the bits in every variable in the
array, converting all instances of the text string "/usr" in memory
to "fsck", changing the colours of your screen to purple, calling the
police on your modem line and telling them you're being attacked by
a one-eyed Martian wielding a herring while singing "Hi ho, it's off
to work we go", and even weirder stuff.
So... what it all boils to... when writing your compiler, just flip
a coin and use the one of the two behaviours you listed that
corresponds with the coin's face.</code></pre>