Files
clang-p2996/compiler-rt/test/asan/TestCases/partial_right.cpp
Florian Mayer be366041fa [ASan] rename left/right to before/after.
left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D132611
2022-09-06 13:25:15 -07:00

14 lines
586 B
C++

// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %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 after {{.*}}-byte region [{{.*}},{{.*}}[[ADDR]])
return res;
}