1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <unistd.h> 4 5 void *Thread(void *a) { 6 sleep(1); 7 __atomic_fetch_add((int*)a, 1, __ATOMIC_SEQ_CST); 8 return 0; 9 } 10 11 int main() { 12 int *a = new int(0); 13 pthread_t t; 14 pthread_create(&t, 0, Thread, a); 15 delete a; 16 pthread_join(t, 0); 17 } 18 19 // CHECK: WARNING: ThreadSanitizer: heap-use-after-free 20