1 | // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t |
2 | // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t |
3 | // RUN: %run %t 2>&1 |
4 | // |
5 | |
6 | #include "sanitizer/asan_interface.h" |
7 | #include <assert.h> |
8 | #include <stdint.h> |
9 | |
10 | __attribute__((noinline)) void foo(int index, int len) { |
11 | volatile char str[len] __attribute__((aligned(32))); |
12 | assert(!(reinterpret_cast<uintptr_t>(str) & 31L)); |
13 | char *q = (char *)__asan_region_is_poisoned(beg: (char *)str, size: 64); |
14 | assert(q && ((q - str) == index)); |
15 | } |
16 | |
17 | int main(int argc, char **argv) { |
18 | for (int i = 1; i < 33; ++i) |
19 | foo(index: i, len: i); |
20 | |
21 | for (int i = 1; i < 33; ++i) |
22 | foo(index: i, len: i); |
23 | |
24 | return 0; |
25 | } |
26 | |