[Bug c/60619] new -solve-sign-conflicts at -Wsign-compare cases (easy work)
aleks at physik dot tu-berlin.de
gcc-bugzilla@gcc.gnu.org
Sat Mar 22 02:06:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60619
--- Comment #2 from Alexander Kleinsorge <aleks at physik dot tu-berlin.de> ---
(In reply to Andrew Pinski from comment #1)
> Well your option violates C promotion rules. Basically the warning is there
> as some folks don't understand how promotion works in C when it comes to
> comparing unsigned and signed integers against each other.
>
> For equals, most of the time you want bytewise comparison; that is the
> implicate cast does not change the bits. While your switch does change the
> bits.
I understand the promotion rules. Nobody is forced to used this new switch.
It gives the fast possibility to see the code as it is written from math
perspective. e.g. (-1 != 0xffFFffFFu) even if both bit representation is ~0
What happens in reallity (not enough programming time):
(s != u) ==> ((unsigned)s != u) , the typecast is inserted to avoid the
warning, not because it is really meant!
This could fasten some cases. The sign-warning could still be there (as without
new switch).
Alex
More information about the Gcc-bugs
mailing list