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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to