fix WARN_ON handling some more
[smatch.git] / validation / sm_array_overflow2.c
blobd0e9a2972ee5aa0100d694cfd59095f6dde1f387
1 #include <stdio.h>
3 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
5 int a[] = {1, 2, 3, 4};
6 int b[] = {
7 [3] = 1,
8 };
10 int x;
11 int main(void)
13 if (x < ARRAY_SIZE(a))
14 a[x] = 1;
15 if (x < ARRAY_SIZE(b))
16 b[x] = 1;
17 if (x < ARRAY_SIZE(b))
18 b[4] = 1;
19 printf("%d\n", ARRAY_SIZE(b));
22 * check-name: smatch indexed array check
23 * check-command: smatch sm_array_overflow2.c
25 * check-output-start
26 sm_array_overflow2.c +18 main(7) error: buffer overflow 'b' 4 <= 4
27 * check-output-end