[LLVMbugs] [Bug 24026] New: No warning on shifting a negative value
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 3 16:01:26 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24026
Bug ID: 24026
Summary: No warning on shifting a negative value
Product: clang
Version: 3.6
Hardware: PC
OS: Windows NT
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
When we shift a negative number, clang does not emit a warning. This is
undefined behavior, which is already captured by ubsan.
$: cat t.c
#include <stdio.h>
int main(int argc, char **argv) {
int a = -1 << 3;
printf("%d\n", a);
return a;
}
$: clang-3.6 t.c ; ./a.out
-8
$: clang-3.6 -fsanitize=undefined t.c ; ./a.out
t.c:3:14: runtime error: left shift of negative value -1
-8
$:
$: gcc-trunk -pedantic -Wshift-negative-value t.c
t.c: In function ‘main’:
t.c:3:14: warning: left shift of negative value [-Wshift-negative-value]
int a = -1 << 3;
^
--
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/20150703/f28c1382/attachment.html>
More information about the llvm-bugs
mailing list