[Bug c/50975] Logical operators evaluated in wrong order if no side effects
gcc.hall at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 3 12:38:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50975
--- Comment #2 from Jeremy <gcc.hall at gmail dot com> 2011-11-03 12:37:41 UTC ---
(In reply to comment #1)
> But ... you can't tell the difference. So this is a valid optimization.
You can tell the difference in execution time.
And why is this an "optimization"? In this case, I cant see how it can improve
the code other than to lose any input from the programmer, who knows when the
data is biased. I guess it might help in a more complex expression.
I think this is different from the controversy over the handling of signed
integer overflow. There is no undefined behavior here. The language standard
from K&R to the present day explicitly states the evaluation order is
guaranteed left to right with these operators.
More information about the Gcc-bugs
mailing list