1*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s 2*7c3d14c8STreehugger Robot #include "test.h" 3*7c3d14c8STreehugger Robot 4*7c3d14c8STreehugger Robot _Atomic(int*) p; 5*7c3d14c8STreehugger Robot thr(void * a)6*7c3d14c8STreehugger Robotvoid *thr(void *a) { 7*7c3d14c8STreehugger Robot barrier_wait(&barrier); 8*7c3d14c8STreehugger Robot int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED); 9*7c3d14c8STreehugger Robot *pp = 42; 10*7c3d14c8STreehugger Robot return 0; 11*7c3d14c8STreehugger Robot } 12*7c3d14c8STreehugger Robot main()13*7c3d14c8STreehugger Robotint main() { 14*7c3d14c8STreehugger Robot barrier_init(&barrier, 2); 15*7c3d14c8STreehugger Robot pthread_t th; 16*7c3d14c8STreehugger Robot pthread_create(&th, 0, thr, p); 17*7c3d14c8STreehugger Robot __c11_atomic_store(&p, new int, __ATOMIC_RELAXED); 18*7c3d14c8STreehugger Robot barrier_wait(&barrier); 19*7c3d14c8STreehugger Robot pthread_join(th, 0); 20*7c3d14c8STreehugger Robot } 21*7c3d14c8STreehugger Robot 22*7c3d14c8STreehugger Robot // CHECK: data race 23*7c3d14c8STreehugger Robot // CHECK: Previous write 24*7c3d14c8STreehugger Robot // CHECK: #0 operator new 25*7c3d14c8STreehugger Robot // CHECK: Location is heap block 26*7c3d14c8STreehugger Robot // CHECK: #0 operator new 27