[LLVMbugs] [Bug 24035] New: false positive, -Wsign-compare, signed value obviously can't be negative

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 6 00:51:00 PDT 2015


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

            Bug ID: 24035
           Summary: false positive, -Wsign-compare, signed value obviously
                    can't be negative
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: daniel.marjamaki at evidente.se
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code:

unsigned int dostuff();
void f(int x) {
  if (x >= 0 && x < dostuff()) {}
}

Output:

signcompare.c:3:19: warning: comparison of integers of different signs: 'int'
and 'unsigned int' [-Wsign-compare]
  if (x >= 0 && x < dostuff()) {}
                ~ ^ ~~~~~~~~~

it is obvious there can't be a bug here so there should not be a warning.

This kind of false positive is indirectly a security problem. People routinely
hide these false positives using casts or changed variable types etc. and that
cause bugs and hides other real warnings.

-- 
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/20150706/20326cd3/attachment.html>


More information about the llvm-bugs mailing list