[LLVMbugs] [Bug 22223] New: inconsistent -Wsign-compare warnings due to type cast

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 14 00:17:56 PST 2015


            Bug ID: 22223
           Summary: inconsistent -Wsign-compare warnings due to type cast
           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

If I add the type cast (int)(0 > a), Clang warns. Otherwise not. 

$: cat s.c
int a;
void fn1(int b) { 
  0xEE5FD967FC84F78BLL <= ((int)(0 > a) / (long long)1); //<-warning here
  0xEE5FD967FC84F78BLL <= (     (0 > a) / (long long)1); //<-NO warning
$: clang-trunk -c s.c -Wsign-compare -Wno-unused-value
s.c:3:24: warning: comparison of integers of different signs: 'unsigned long
long' and 'long long'
  0xEE5FD967FC84F78BLL <= ((int)(0 > a) / (long long)1); //<-warning here
  ~~~~~~~~~~~~~~~~~~~~ ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
$: gcc-trunk -c s.c -Wsign-compare 

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/20150114/f2ed1b4f/attachment.html>

More information about the llvm-bugs mailing list