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