summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/lit_tests/TestCases/partial_right.cc
blob: a000a913d6bee6e6d25fea2b508e54365bf29c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s

#include <stdlib.h>
int main(int argc, char **argv) {
  volatile int *x = (int*)malloc(2*sizeof(int) + 2);
  int res = x[2];  // BOOOM
  // CHECK: {{READ of size 4 at 0x.* thread T0}}
  // CHECK: [[ADDR:0x[01-9a-fa-f]+]] is located 0 bytes to the right of {{.*}}-byte region [{{.*}},{{.*}}[[ADDR]])
  return res;
}
OpenPOWER on IntegriCloud