1 // RUN: %clang_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <unistd.h> 4 5 _Atomic(int*) p; 6 7 void *thr(void *a) { 8 sleep(1); 9 int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED); 10 *pp = 42; 11 return 0; 12 } 13 14 int main() { 15 pthread_t th; 16 pthread_create(&th, 0, thr, p); 17 __c11_atomic_store(&p, new int, __ATOMIC_RELAXED); 18 pthread_join(th, 0); 19 } 20 21 // CHECK: data race 22 // CHECK: Previous write 23 // CHECK: #0 operator new 24 // CHECK: Location is heap block 25 // CHECK: #0 operator new 26