[llvm-bugs] [Bug 40234] New: clang should warn about unsigned comparison with zero with -Wall -Wextra

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 5 12:17:30 PST 2019


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

            Bug ID: 40234
           Summary: clang should warn about unsigned comparison with zero
                    with -Wall -Wextra
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tblodt at icloud.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Given this function:

int f(unsigned x) {
    return x < 0;
}

GCC gives the following warning with -Wextra:

<source>: In function 'int f(unsigned int)':
<source>:2:14: warning: comparison of unsigned expression < 0 is always false
[-Wtype-limits]
     return x < 0;
            ~~^~~

Clang doesn't warn at all, even with -Wall -Wextra. You need to specify
-Wtautological-constant-in-range-compare, which is really hard to figure out.

-- 
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/20190105/d0a71dca/attachment.html>


More information about the llvm-bugs mailing list