[Bug c/54979] New: no warning for useless comparison
tromey at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 18 19:52:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list