[LLVMbugs] [Bug 24238] New: False Positive of -Wtautological-overlap-compare on Expressions in Return Statement

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 23 16:54:29 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150723/1c6551a7/attachment.html>


More information about the llvm-bugs mailing list