• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include "test.h"
3 
Thread(void * p)4 void *Thread(void *p) {
5   *(int*)p = 42;
6   barrier_wait(&barrier);
7   return 0;
8 }
9 
main()10 int main() {
11   barrier_init(&barrier, 2);
12   int *p = new int(0);
13   pthread_t t;
14   pthread_create(&t, 0, Thread, p);
15   barrier_wait(&barrier);
16   AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
17   AnnotateIgnoreWritesBegin(__FILE__, __LINE__);
18   free(p);
19   AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
20   AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
21   pthread_join(t, 0);
22   fprintf(stderr, "OK\n");
23   return 0;
24 }
25 
26 // CHECK-NOT: WARNING: ThreadSanitizer: data race
27 // CHECK: OK
28