I heard that C compiler with/without optimization option may generate different program(compiling the program with optimizations causes it to behave differently), but I never encountered such case.
Anyone can give simple example to show this?
I heard that C compiler with/without optimization option may generate different program(compiling the program
Share
For gcc 4.4.4, this differs with
-O0and-O2With optimizations this loops forever. Without optimizations, it crashes (stack overflow!)
Other and more realistic variants would typically be dependent on timing, vulnerable to float exactness variations, or depending on undefined behavior (uninitialized variables, heap/stack layout)