Home | History | Annotate | Download | only in lit_tests
      1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
      2 #include <pthread.h>
      3 
      4 volatile int N;  // Prevent loop unrolling.
      5 int **data;
      6 
      7 void *Thread1(void *x) {
      8   for (int i = 0; i < N; i++)
      9     data[i][0] = 42;
     10   return 0;
     11 }
     12 
     13 int main() {
     14   N = 4;
     15   data = new int*[N];
     16   for (int i = 0; i < N; i++)
     17     data[i] = new int;
     18   pthread_t t;
     19   pthread_create(&t, 0, Thread1, 0);
     20   Thread1(0);
     21   pthread_join(t, 0);
     22   for (int i = 0; i < N; i++)
     23     delete data[i];
     24   delete[] data;
     25 }
     26 
     27 // CHECK: ThreadSanitizer: reported 1 warnings
     28