Home | History | Annotate | Download | only in tsan
      1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
      2 #include "test.h"
      3 #include <pthread.h>
      4 #include <stdio.h>
      5 #include <stddef.h>
      6 
      7 void *Thread(void *a) {
      8   ((int*)a)[0]++;
      9   barrier_wait(&barrier);
     10   return NULL;
     11 }
     12 
     13 int main() {
     14   barrier_init(&barrier, 2);
     15   int *p = new int(42);
     16   pthread_t t;
     17   pthread_create(&t, NULL, Thread, p);
     18   barrier_wait(&barrier);
     19   p[0]++;
     20   pthread_join(t, NULL);
     21   delete p;
     22 }
     23 
     24 // CHECK: WARNING: ThreadSanitizer: data race
     25