Compiler output code

110 views Asked by At

Are there real world cases where compilers in C produced object code that functioned almost identically as the source code described, but in the end turned out that the optimizations turned (or could turn) disastrous?

1

There are 1 answers

4
Shiro On

Example: if(something || i++). Let's assume something is true. An optimization would be to just skip i++ since the or statement is already true. It depends on the compiler and its configuration whether the second statement is actually executed or not. So this would be the one example I can think of where the compiler optimizations could lead to 'unexpected' results.