[llvm-bugs] [Bug 37113] New: No -Wtautological-compare warning issued

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 12 12:45:12 PDT 2018


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: unassignedclangbugs at nondot.org
          Reporter: riyaz at synopsys.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180412/70d49fb7/attachment.html>


More information about the llvm-bugs mailing list