[LLVMbugs] [Bug 15489] New: no warning for bool compared to out-of-range constant

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 11 12:23:20 PDT 2013


            Bug ID: 15489
           Summary: no warning for bool compared to out-of-range constant
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: b.r.longbons at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang does not warn (even with -Weverything) for the comparison of a boolean to
a constant integer with a value other than 0 or 1.

This should be covered by -Wtautological-compare at least, or maybe even
enabled by default.

This is a subset of the RFE in bug #7866, but should be enabled separately
since this is probably ALWAYS a bug, whereas that one might be legitimate in
old code.

Sample code:
bool check1(bool v)
    return v == -1;

bool check2(struct Foo *p)
    return !p == -1; // evil half-refactoring ...

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/20130311/1646d1dd/attachment.html>

More information about the llvm-bugs mailing list