blob: 634eb80bafa0507d736594749f6b77cab033e1ea [file] [log] [blame]
Kostya Serebryanya89a35a2013-03-26 08:01:37 +00001// Check that __asan_poison_memory_region works.
2// RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
3//
4// Check that we can disable it
5// RUN: ASAN_OPTIONS=allow_user_poisoning=0 %t
6
7#include <stdlib.h>
8
9extern "C" void __asan_poison_memory_region(void *, size_t);
10
11int main(int argc, char **argv) {
12 char *x = new char[16];
13 __asan_poison_memory_region(x, 16);
14 int res = x[argc * 10]; // BOOOM
15 // CHECK: ERROR: AddressSanitizer: use-after-poison
16 // CHECK: main{{.*}}use-after-poison.cc:[[@LINE-2]]
17 delete [] x;
18 return res;
19}