1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <stdio.h> 4 5 const long kOffset = 64*1024; 6 7 void *Thread(void *p) { 8 ((char*)p)[-kOffset] = 43; 9 return 0; 10 } 11 12 int main() { 13 char *volatile p0 = new char[16]; 14 delete[] p0; 15 char *p = new char[32]; 16 pthread_t th; 17 pthread_create(&th, 0, Thread, p); 18 p[-kOffset] = 42; 19 pthread_join(th, 0); 20 } 21 22 // Used to crash with CHECK failed. 23 // CHECK: WARNING: ThreadSanitizer: data race 24 25