This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/66773] sign-compare warning for == and != are pretty useless
- From: "daniel.marjamaki at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 06 Jul 2015 23:06:20 +0000
- Subject: [Bug c/66773] sign-compare warning for == and != are pretty useless
- Auto-submitted: auto-generated
- References: <bug-66773-4 at http dot gcc dot gnu dot org/bugzilla/>
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.