> Compiler can optimize it any way it wants,
> as long as result is the same as unoptimized one.

We have an option for that. It's called -O0.

Pretty much all optimization will change the behavior of your program. The 
important distinction is whether that difference is observable in valid 
programs. The whole point of langage standards is that they define what 
constitutes a valid program.

By your definition all writes to vairables must translate into a write to 
memory (for "correct" behavior in multithreaded applications and with signal 
handlers). This implies all variables are effectively volatile.

You can argue that signed overflow is an extension that it's worth supporting 
by default. Other people (eg. those interested in autovectorization) will 
argue that it provides useful optimization opportunities. I don't know which 
of these is better, but either what it's a lot different to saying "never 
change the behavior of any program.

Paul


Reply via email to