1 // RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe && %deflake %run %T/global_race.cc.exe | FileCheck %s 2 #include "test.h" 3 4 int GlobalData[10]; 5 Thread(void * a)6void *Thread(void *a) { 7 barrier_wait(&barrier); 8 GlobalData[2] = 42; 9 return 0; 10 } 11 main()12int main() { 13 barrier_init(&barrier, 2); 14 print_address("addr=", 1, GlobalData); 15 pthread_t t; 16 pthread_create(&t, 0, Thread, 0); 17 GlobalData[2] = 43; 18 barrier_wait(&barrier); 19 pthread_join(t, 0); 20 } 21 22 // CHECK: addr=[[ADDR:0x[0-9,a-f]+]] 23 // CHECK: WARNING: ThreadSanitizer: data race 24 // CHECK: Location is global 'GlobalData' {{(of size 40 )?}}at [[ADDR]] (global_race.cc.exe+0x{{[0-9,a-f]+}}) 25 26