Home | History | Annotate | Download | only in tsan
      1 // RUN: %clangxx_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
      2 #include "test.h"
      3 
      4 const int kThreads = 16;
      5 const int kIters = 1000;
      6 
      7 volatile int X = 0;
      8 
      9 void *thr(void *arg) {
     10   for (int i = 0; i < kIters; i++)
     11     X++;
     12   return 0;
     13 }
     14 
     15 int main() {
     16   pthread_t th[kThreads];
     17   for (int i = 0; i < kThreads; i++)
     18     pthread_create(&th[i], 0, thr, 0);
     19   for (int i = 0; i < kThreads; i++)
     20     pthread_join(th[i], 0);
     21   fprintf(stderr, "DONE\n");
     22 }
     23 
     24 // CHECK: ThreadSanitizer: data race
     25 // CHECK: DONE
     26