[LLVMbugs] [Bug 3333] New: No warning when shifting invalid amount

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jan 15 11:43:34 PST 2009


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

           Summary: No warning when shifting invalid amount
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: alexei.svitkine at gmail.com
                CC: llvmbugs at cs.uiuc.edu


When using operators ">>" or "<<", the valid range for the shift amount is [0,
# bits in type).

GCC gives appropriate warnings when the shift amount is an out-of-range
constant, such as:

"warning: right shift count is negative"

and

"warning: left shift count >= width of type"

However, clang does not present any warnings on the same code. An example
input:

#include <stdio.h>

int main(void)
{
        int i = 1;
        printf("%d\n", i>>-1);
        return 0;
}


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list