Home | History | Annotate | Download | only in tsan
      1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
      2 #include <pthread.h>
      3 #include <stdio.h>
      4 #include <stddef.h>
      5 #include <unistd.h>
      6 
      7 int x;
      8 
      9 void *Thread(void *a) {
     10   sleep(1);
     11   x = 1;
     12   return 0;
     13 }
     14 
     15 int main() {
     16   fprintf(stderr, "addr2=%p\n", &x);
     17   pthread_t t;
     18   pthread_create(&t, 0, Thread, 0);
     19   x = 0;
     20   pthread_join(t, 0);
     21 }
     22 
     23 // CHECK: addr2=[[ADDR2:0x[0-9,a-f]+]]
     24 // CHECK: WARNING: ThreadSanitizer: data race
     25 // CHECK: Location is global 'x' of size 4 at [[ADDR2]] ({{.*}}+0x{{[0-9,a-f]+}})
     26 
     27