[LLVMbugs] [Bug 22899] New: false negative of -Winteger-overflow
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Mar 13 16:54:25 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=22899
Bug ID: 22899
Summary: false negative of -Winteger-overflow
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
Clang warns on integer overflow in variable initialization but not assignment.
For example, there is warning on
int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
But if I split the statement into two, Clang will not warn:
int b;
b = ((uint16_t)0xE570L * (uint16_t)(-1L));
$: cat t.c
#include <stdint.h>
int main(void) {
int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
int b;
b = ((uint16_t)0xE570L * (uint16_t)(-1L));
return 0;
}
$: clang-trunk -Wconversion t.c
t.c:3:30: warning: overflow in expression; result is -445703536 with type 'int'
[-Winteger-overflow]
int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
^
1 warning generated.
$: gcc-trunk -Wconversion t.c
t.c: In function ‘main’:
t.c:3:30: warning: integer overflow in expression [-Woverflow]
int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
^
t.c:5:26: warning: integer overflow in expression [-Woverflow]
b = ((uint16_t)0xE570L * (uint16_t)(-1L));
^
$:
--
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/20150313/4000dc9d/attachment.html>
More information about the llvm-bugs
mailing list