https://bugs.llvm.org/show_bug.cgi?id=37113

            Bug ID: 37113
           Summary: No -Wtautological-compare warning issued
           Product: clang
           Version: 6.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: ri...@synopsys.com
                CC: llvm-bugs@lists.llvm.org

For the following simple test case, clang fails to issue a
-Wtautological-compare warning. gcc 6.2 issues this warning.

If there was no pointer deference (and there was a self compare on a simple
int), then clang would issue the warning as expected. The pointed memory is not
volatile and clang -O1 optimizes away the two comparisons that would always
evaluate to false. So it is reasonable to expect that it should warn about them
as well.

struct Foo {
    int a;
};

int cmp(const Foo* x, const Foo* y);
int cmp(const Foo* x, const Foo* y)
{
    if (x->a < x->a) {
        return -1;
    } else if (y->a > y->a) {
        return 1;
    }
    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to