1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5
6 struct P {
7 int x;
8 int y;
9 };
10
Thread(void * x)11 void *Thread(void *x) {
12 static P p = {rand(), rand()};
13 if (p.x > RAND_MAX || p.y > RAND_MAX)
14 exit(1);
15 return 0;
16 }
17
main()18 int main() {
19 pthread_t t[2];
20 pthread_create(&t[0], 0, Thread, 0);
21 pthread_create(&t[1], 0, Thread, 0);
22 pthread_join(t[0], 0);
23 pthread_join(t[1], 0);
24 fprintf(stderr, "PASS\n");
25 }
26
27 // CHECK-NOT: WARNING: ThreadSanitizer: data race
28