db: get return states from function pointers if possible
[smatch.git] / validation / sm_array_overflow2.c
blob6cfcd7092c5135fcaacf9b223886831ca0a78781
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() error: buffer overflow 'b' 4 <= 4
27 * check-output-end