1 | // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s |
2 | |
3 | // FIXME: Doesn't work with DLLs |
4 | // XFAIL: win32-dynamic-asan |
5 | |
6 | #include <stdio.h> |
7 | #include <stdlib.h> |
8 | |
9 | // Required for dyld macOS 12.0+ |
10 | #if (__APPLE__) |
11 | __attribute__((weak)) |
12 | #endif |
13 | extern "C" void |
14 | __asan_on_error() { |
15 | fprintf(stderr, format: "__asan_on_error called\n" ); |
16 | fflush(stderr); |
17 | } |
18 | |
19 | int main() { |
20 | char *x = (char*)malloc(size: 10 * sizeof(char)); |
21 | free(ptr: x); |
22 | return x[5]; |
23 | // CHECK: __asan_on_error called |
24 | } |
25 | |