3 ms·
I think they have to produce different code by definition, because these two have different meaning (in C++, at least). In the prefix form (the first one) the
by nice_byte 10y ago
I think they have to produce different code by definition, because these two have different meaning (in C++, at least).
In the prefix form (the first one) the expression's result is the incremented value, while in the postfix form, the expression's result is the value before it was incremented.
However, compilers are so crazy with optimizations these days that I wouldn't be surprised if they can figure out that the code isn't actually relying on the semantics of the postfix form and convert it to prefix form.