[LLVMbugs] [Bug 17490] New: ubsan: Left shift of negative value in c89

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Oct 6 23:25:54 PDT 2013


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

            Bug ID: 17490
           Summary: ubsan: Left shift of negative value in c89
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: silvas at purdue.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

c89 doesn't seem to have the "If E1 has a signed type and nonnegative value,
and E1 × 2^E2 is representable in the result type, then that is the resulting
value; otherwise, the behavior is undefined." wording, so this diagnostic is
spurious:

sean:~/tmp % cat left_shift_negative.c                                          
int main(int argc, char **argv) {
  return (-argc) << 2;
}
sean:~/tmp % clang -std=c89 -fsanitize=undefined left_shift_negative.c          
sean:~/tmp % ./a.out
left_shift_negative.c:2:18: runtime error: left shift of negative value -1

-- 
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/20131007/ffcb3761/attachment.html>


More information about the llvm-bugs mailing list