1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
2*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
3*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
4*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
5*7c3d14c8STreehugger Robot // XFAIL: arm-linux-gnueabi
6*7c3d14c8STreehugger Robot // XFAIL: armv7l-unknown-linux-gnueabihf
7*7c3d14c8STreehugger Robot
8*7c3d14c8STreehugger Robot #include <stdlib.h>
main()9*7c3d14c8STreehugger Robot int main() {
10*7c3d14c8STreehugger Robot char * volatile x = new char[10];
11*7c3d14c8STreehugger Robot delete[] x;
12*7c3d14c8STreehugger Robot return x[5];
13*7c3d14c8STreehugger Robot // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
14*7c3d14c8STreehugger Robot // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
15*7c3d14c8STreehugger Robot // CHECK: {{READ of size 1 at 0x.* thread T0}}
16*7c3d14c8STreehugger Robot // CHECK: {{ #0 0x.* in main .*use-after-delete.cc:}}[[@LINE-4]]
17*7c3d14c8STreehugger Robot // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
18*7c3d14c8STreehugger Robot // CHECK: {{freed by thread T0 here:}}
19*7c3d14c8STreehugger Robot
20*7c3d14c8STreehugger Robot // CHECK-Linux: {{ #0 0x.* in operator delete\[\]}}
21*7c3d14c8STreehugger Robot // CHECK-Linux: {{ #1 0x.* in main .*use-after-delete.cc:}}[[@LINE-10]]
22*7c3d14c8STreehugger Robot
23*7c3d14c8STreehugger Robot // CHECK: {{previously allocated by thread T0 here:}}
24*7c3d14c8STreehugger Robot
25*7c3d14c8STreehugger Robot // CHECK-Linux: {{ #0 0x.* in operator new\[\]}}
26*7c3d14c8STreehugger Robot // CHECK-Linux: {{ #1 0x.* in main .*use-after-delete.cc:}}[[@LINE-16]]
27*7c3d14c8STreehugger Robot
28*7c3d14c8STreehugger Robot // CHECK: Shadow byte legend (one shadow byte represents 8 application bytes):
29*7c3d14c8STreehugger Robot // CHECK: Global redzone:
30*7c3d14c8STreehugger Robot // CHECK: ASan internal:
31*7c3d14c8STreehugger Robot }
32