Van Eps, Nathan D. (James Tower) <[EMAIL PROTECTED]> wrote:
>>From: Eamon Caddigan
>>
>>>Van Eps, Nathan D. (James Tower) <[EMAIL PROTECTED]> wrote:
>>> That is weird. A compiler should generate the same code whether it is
>>> optimized or unoptimized. It would be interesting to hear an explanation
>>> from the gcc folk as to what causes this.
>>
>>Plenty of programs break when compiled with aggressive optimizations --
>>why should a compiler be any different?
> 
> If the compiler broke (because of aggressive optimizations), the compiler
> wouldn't make an executable. And if you compiled the compiler with good
> optimizations, the compiler would simply run faster (not the executable it
> generates). Its like deterministic.
> 
> You expect your programs to run the same regardless of compiler
> optimization. You just want them to run faster...

That's a fair expectation, but not quite how it works. When optimizing
code, compilers rearrange instructions (among other things) to achieve
faster (or smaller, etc.) code. It's not too difficult to imagine an
incorrectly-optimized compiler creating executables that themselves
fail, rather then simply refusing to compile any code. Especially when
you consider how subtle the problems introduced by incorrect
"optimizations" can be.

-Eamon


--
[EMAIL PROTECTED] mailing list

Reply via email to