http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46680

--- Comment #2 from Adriano Rezende <adriano.rezende at openbossa dot org> 
2010-11-27 12:10:21 UTC ---
>> Am I missing something?

> -O1 / -O2 / -O3 / -Os option.

I know about these optimization flags :).
My suggestion is directed specifically to -O0.

I would not rest knowing that it generates 4 instructions per comparison, while
it could use 2 instructions, reducing my code size and my compilation time
while using -O0, which is the default one.

>> but I think this is a strange behavior
>> even for non-initialized variables.

> http://en.wikipedia.org/wiki/Undefined_behavior

I also know about UB. The strange behavior I'm referring to regards the
compiler implementation rather than the language specification. I just looked
for this, because I expected a consistent behavior in gcc for non-initialized
bool values in that matter. For example, for char types it wouldn't make sense
a == !a, for whatever value randomly placed in those 8 bits. For the 'if'
statements, I expected a mutual exclusive operation, like [if(a) - cmpb/je] and
[if(!a) - cmpb/jne], and that wasn't happening for bool comparisons.

Well, I'm not an asm programmer nor a gcc contributor, so I may be wrong. But
unless those 4 instructions make some sense, there is no purpose in keeping
them.

Reply via email to