This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/54979] New: no warning for useless comparison


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]