https://llvm.org/bugs/show_bug.cgi?id=27439
Bug ID: 27439
Summary: No warning for integer overflow in array size
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
While compiling this program:
#include <limits.h>
int main()
{
char a[INT_MAX * 3];
(void)(INT_MAX * 3);
}
clang 3.9.0 (trunk 266734) gives the following warnings:
$ clang example.c
example.c:6:18: warning: overflow in expression; result is 2147483645 with type
'int' [-Winteger-overflow]
(void)(INT_MAX * 3);
^
1 warning generated.
There is no warning for the integer overflow in the declaration of the array.
UBSAN doesn't help.
For comparison:
$ gcc example.c
example.c: In function ‘main’:
example.c:5:18: warning: integer overflow in expression [-Woverflow]
char a[INT_MAX * 3];
^
example.c:6:18: warning: integer overflow in expression [-Woverflow]
(void)(INT_MAX * 3);
^
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs