[LLVMbugs] [Bug 22253] New: -Wdivision-by-zero does not warn on "1000 / (unsigned char)(a << 8)"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jan 17 01:19:26 PST 2015


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

            Bug ID: 22253
           Summary: -Wdivision-by-zero does not warn on "1000 / (unsigned
                    char)(a << 8)"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I think the current -Wdivision-by-zero can be improved by considering to
support the following case, where "(unsigned char)(a << 8)" is zero. 


$: cat s.c 
int a;
int fn1() { 
  return 1000 / (unsigned char)(a << 8); 
}
$: 
$: gcc-trunk -c s.c -Wdiv-by-zero
s.c: In function ‘fn1’:
s.c:3:15: warning: division by zero [-Wdiv-by-zero]
   return 1000 / (unsigned char)(a << 8); 
               ^
$: 
$: clang-trunk -c s.c -Wdivision-by-zero
$:

-- 
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/20150117/1f0e008e/attachment.html>


More information about the llvm-bugs mailing list