This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54979] New: no warning for useless comparison
- From: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 18 Oct 2012 19:52:24 +0000
- Subject: [Bug c/54979] New: no warning for useless comparison
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54979
Bug #: 54979
Summary: no warning for useless comparison
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tromey@gcc.gnu.org
gdb had code similar to this:
int comp(int x, int y)
{
return x > x ? 1 : 0;
}
The comparison here is useless; what was meant was "x > y".
clang detects this:
a.c:3:12: warning: self-comparison always evaluates to false
[-Wtautological-compare]
return x > x ? 1 : 0;
^
... but I couldn't find a gcc warning for this.