1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <stdio.h> 4 __tsan_default_options()5extern "C" const char *__tsan_default_options() { 6 return "report_bugs=0"; 7 } 8 9 int Global; 10 Thread1(void * x)11void *Thread1(void *x) { 12 Global = 42; 13 return NULL; 14 } 15 Thread2(void * x)16void *Thread2(void *x) { 17 Global = 43; 18 return NULL; 19 } 20 main()21int main() { 22 pthread_t t[2]; 23 pthread_create(&t[0], NULL, Thread1, NULL); 24 pthread_create(&t[1], NULL, Thread2, NULL); 25 pthread_join(t[0], NULL); 26 pthread_join(t[1], NULL); 27 fprintf(stderr, "DONE\n"); 28 return 0; 29 } 30 31 // CHECK-NOT: WARNING: ThreadSanitizer: data race 32 // CHECK: DONE 33