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