http://llvm.org/bugs/show_bug.cgi?id=18691

Chengnian Sun <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Chengnian Sun <[email protected]> ---
I found another test case. I am not sure whether I should open another report,
so just reopen this one. 


Wtautological-constant-out-of-range-compare does not warn on the following
case, which has a type conversion from bool to short type. If I remove the type
cast, Clang warns.  

/////////////////////////////////////////////////////////
// test case on which clang does not warn 
/////////////////////////////////////////////////////////
$: cat t.c
int f(int a) {
  return 999 != (short)(a == 1);
}
$: 
$: clang-trunk -Weverything -c t.c
t.c:1:5: warning: no previous prototype for function 'f' [-Wmissing-prototypes]
int f(int a) {
    ^
1 warning generated.
$: 
$: gcc-trunk -c t.c -Wall
t.c: In function ‘f’:
t.c:2:14: warning: comparison of constant ‘999’ with boolean expression is
always true [-Wbool-compare]
   return 999 != (short)(a == 1);
              ^
$: 




/////////////////////////////////////////////////////////
// clang warns on the following case 
/////////////////////////////////////////////////////////
$: cat t.c
int f(int a) {
  return 999 != (a == 1);
}
$: 
$: clang-trunk -Weverything -c t.c
t.c:1:5: warning: no previous prototype for function 'f' [-Wmissing-prototypes]
int f(int a) {
    ^
t.c:2:14: warning: comparison of constant 999 with boolean expression is always
      true [-Wtautological-constant-out-of-range-compare]
  return 999 != (a == 1);
         ~~~ ^  ~~~~~~~~
2 warnings generated.
$: 
$: gcc-trunk -c t.c -Wall
t.c: In function ‘f’:
t.c:2:14: warning: comparison of constant ‘999’ with boolean expression is
always true [-Wbool-compare]
   return 999 != (a == 1);
              ^
$:

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