Anna K.
Anna K.

Reputation: 205

Compiler output code

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?

Upvotes: 1

Views: 114

Answers (1)

user6499716
user6499716

Reputation:

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.

Upvotes: 0

Related Questions