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 
      4 int x;
      5 
      6 void *Thread(void *a) {
      7   barrier_wait(&barrier);
      8   x = 1;
      9   return 0;
     10 }
     11 
     12 int main() {
     13   barrier_init(&barrier, 2);
     14   fprintf(stderr, "addr2=");
     15   print_address(&x);
     16   fprintf(stderr, "\n");
     17   pthread_t t;
     18   pthread_create(&t, 0, Thread, 0);
     19   x = 0;
     20   barrier_wait(&barrier);
     21   pthread_join(t, 0);
     22 }
     23 
     24 // CHECK: addr2=[[ADDR2:0x[0-9,a-f]+]]
     25 // CHECK: WARNING: ThreadSanitizer: data race
     26 // CHECK: Location is global 'x' of size 4 at [[ADDR2]] ({{.*}}+0x{{[0-9,a-f]+}})
     27 
     28