[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / tls_race2.cc
blobed9f4d0faf380c0a899d99a8cf58915564be2224
1 // RUN: %clangxx_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stddef.h>
4 #include <unistd.h>
6 void *Thread2(void *a) {
7 sleep(1);
8 *(int*)a = 43;
9 return 0;
12 void *Thread(void *a) {
13 static __thread int Var = 42;
14 pthread_t t;
15 pthread_create(&t, 0, Thread2, &Var);
16 Var = 42;
17 pthread_join(t, 0);
18 return 0;
21 int main() {
22 pthread_t t;
23 pthread_create(&t, 0, Thread, 0);
24 pthread_join(t, 0);
27 // CHECK: WARNING: ThreadSanitizer: data race
28 // CHECK: Location is TLS of thread T1.