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