1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s 2 #include <pthread.h> 3 #include <stdio.h> 4 #include <stddef.h> 5 #include <unistd.h> 6 7 namespace XXX { 8 struct YYY { 9 static int ZZZ[10]; 10 }; 11 int YYY::ZZZ[10]; 12 } 13 14 void *Thread(void *a) { 15 sleep(1); 16 XXX::YYY::ZZZ[0] = 1; 17 return 0; 18 } 19 20 int main() { 21 fprintf(stderr, "addr3=%p\n", XXX::YYY::ZZZ); 22 pthread_t t; 23 pthread_create(&t, 0, Thread, 0); 24 XXX::YYY::ZZZ[0] = 0; 25 pthread_join(t, 0); 26 } 27 28 // CHECK: addr3=[[ADDR3:0x[0-9,a-f]+]] 29 // CHECK: WARNING: ThreadSanitizer: data race 30 // CHECK: Location is global 'XXX::YYY::ZZZ' of size 40 at [[ADDR3]] ({{.*}}+0x{{[0-9,a-f]+}}) 31