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

            Bug ID: 24238
           Summary: False Positive of -Wtautological-overlap-compare on
                    Expressions in Return Statement
           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

Clang does not warn on the expression "x > 6 && x < 2" in the return statement.
If this expression is in the if conditional, it warns. 

$: cat s.c
int g(int x) {
  return x > 6 && x < 2;
}
int f(int x) {
  if (x > 6 && x < 2) {
    return 1;
  }
  return 0;
}
$: 
$: clang-trunk -Wtautological-overlap-compare -c s.c
s.c:5:13: warning: overlapping comparisons always evaluate to false
[-Wtautological-overlap-compare]
  if (x > 6 && x < 2) {
      ~~~~~~^~~~~~~~
1 warning generated.
$: 
$: gcc-trunk -c -Wlogical-op s.c
s.c: In function ‘g’:
s.c:2:16: warning: logical ‘and’ of mutually exclusive tests is always false
[-Wlogical-op]
   return x > 6 && x < 2;
                ^
s.c: In function ‘f’:
s.c:5:13: warning: logical ‘and’ of mutually exclusive tests is always false
[-Wlogical-op]
   if (x > 6 && x < 2) {
             ^
$:

-- 
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