[Bug c/66773] sign-compare warning for == and != are pretty useless
daniel.marjamaki at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 6 23:06:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66773
--- Comment #4 from Daniel Marjamäki <daniel.marjamaki at gmail dot com> ---
absolutely. there are often bugs in the boundaries.
well. I was hoping to get more optimistic response.
how about this.. imagine that we wrote a "possible division by zero" warning
for every integer division that uses a non-constant rhs. every warning where
rhs can't really be zero would be a false positive. That would be very noisy
imo.
imho the false positive rate should be similar here. If there is a comparison
'a == -1' and a is unsigned then this warning is useless if a can't be
0xffffffff. if a has arbitrary values then statistically it's as likely that a
is 0xffffffff and 0. So I guess the false positive rate is somewhat similar.
Maybe the message can be tweaked?
comparison between signed and unsigned integer expressions [-Wsign-compare]
I think this message is fine for relational comparisons. A sign-cast is a
reasonable solution.
For == and != I am afraid the message is somewhat misleading. A sign-cast is
not a good solution.
More information about the Gcc-bugs
mailing list