1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O2 %s -o %t
2*7c3d14c8STreehugger Robot // RUN: not %run %t -2 2>&1 | FileCheck --check-prefix=CHECK-m2 %s
3*7c3d14c8STreehugger Robot // RUN: not %run %t -1 2>&1 | FileCheck --check-prefix=CHECK-m1 %s
4*7c3d14c8STreehugger Robot // RUN: %run %t 0
5*7c3d14c8STreehugger Robot // RUN: %run %t 8
6*7c3d14c8STreehugger Robot // RUN: not %run %t 9 2>&1 | FileCheck --check-prefix=CHECK-9 %s
7*7c3d14c8STreehugger Robot // RUN: not %run %t 10 2>&1 | FileCheck --check-prefix=CHECK-10 %s
8*7c3d14c8STreehugger Robot // RUN: not %run %t 30 2>&1 | FileCheck --check-prefix=CHECK-30 %s
9*7c3d14c8STreehugger Robot // RUN: not %run %t 31 2>&1 | FileCheck --check-prefix=CHECK-31 %s
10*7c3d14c8STreehugger Robot // RUN: not %run %t 41 2>&1 | FileCheck --check-prefix=CHECK-41 %s
11*7c3d14c8STreehugger Robot // RUN: not %run %t 42 2>&1 | FileCheck --check-prefix=CHECK-42 %s
12*7c3d14c8STreehugger Robot // RUN: not %run %t 62 2>&1 | FileCheck --check-prefix=CHECK-62 %s
13*7c3d14c8STreehugger Robot // RUN: not %run %t 63 2>&1 | FileCheck --check-prefix=CHECK-63 %s
14*7c3d14c8STreehugger Robot // RUN: not %run %t 73 2>&1 | FileCheck --check-prefix=CHECK-73 %s
15*7c3d14c8STreehugger Robot // RUN: not %run %t 74 2>&1 | FileCheck --check-prefix=CHECK-74 %s
16*7c3d14c8STreehugger Robot #include <string.h>
17*7c3d14c8STreehugger Robot #include <stdio.h>
18*7c3d14c8STreehugger Robot #include <stdlib.h>
19*7c3d14c8STreehugger Robot #include <assert.h>
main(int argc,char ** argv)20*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
21*7c3d14c8STreehugger Robot assert(argc >= 2);
22*7c3d14c8STreehugger Robot int idx = atoi(argv[1]);
23*7c3d14c8STreehugger Robot char AAA[10], BBB[10], CCC[10];
24*7c3d14c8STreehugger Robot memset(AAA, 0, sizeof(AAA));
25*7c3d14c8STreehugger Robot memset(BBB, 0, sizeof(BBB));
26*7c3d14c8STreehugger Robot memset(CCC, 0, sizeof(CCC));
27*7c3d14c8STreehugger Robot int res = 0;
28*7c3d14c8STreehugger Robot char *p = AAA + idx;
29*7c3d14c8STreehugger Robot printf("AAA: %p\ny: %p\nz: %p\np: %p\n", AAA, BBB, CCC, p);
30*7c3d14c8STreehugger Robot // make sure BBB and CCC are not removed;
31*7c3d14c8STreehugger Robot return *(short*)(p) + BBB[argc % 2] + CCC[argc % 2];
32*7c3d14c8STreehugger Robot }
33*7c3d14c8STreehugger Robot // CHECK-m2: 'AAA' <== {{.*}}underflows this variable
34*7c3d14c8STreehugger Robot // CHECK-m1: 'AAA' <== {{.*}}partially underflows this variable
35*7c3d14c8STreehugger Robot // CHECK-9: 'AAA' <== {{.*}}partially overflows this variable
36*7c3d14c8STreehugger Robot // CHECK-10: 'AAA' <== {{.*}}overflows this variable
37*7c3d14c8STreehugger Robot // CHECK-30: 'BBB' <== {{.*}}underflows this variable
38*7c3d14c8STreehugger Robot // CHECK-31: 'BBB' <== {{.*}}partially underflows this variable
39*7c3d14c8STreehugger Robot // CHECK-41: 'BBB' <== {{.*}}partially overflows this variable
40*7c3d14c8STreehugger Robot // CHECK-42: 'BBB' <== {{.*}}overflows this variable
41*7c3d14c8STreehugger Robot // CHECK-62: 'CCC' <== {{.*}}underflows this variable
42*7c3d14c8STreehugger Robot // CHECK-63: 'CCC' <== {{.*}}partially underflows this variable
43*7c3d14c8STreehugger Robot // CHECK-73: 'CCC' <== {{.*}}partially overflows this variable
44*7c3d14c8STreehugger Robot // CHECK-74: 'CCC' <== {{.*}}overflows this variable
45