Paul Brook <[EMAIL PROTECTED]> writes:

| > 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.

The problem is that what constitutes a valid program tends to differ
from what constitutes a useful program found in the wild.  The
question for GCC is how to accomodate for the useful uses without
getting far away from both conformance and non-conformance.

I don't believe this particular issue of optimization based on
"undefined behaviour" can be resolved by just telling people "hey
look, the C standard says it is undefined, therefore we can optimize.
And if you're not happy, just tell the compiler not to optimize".
For not all undefined behaviour are equal, and undefined behaviour is
also a latitude given to implementors to better serve their base
users.

-- Gaby


Reply via email to