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