1#include <pthread.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <sched.h>
5
6struct Cache {
7  int x;
8  explicit Cache(int x)
9    : x(x) {
10  }
11};
12
13int g_other;
14
15Cache *CreateCache() {
16  g_other = rand();
17  return new Cache(rand());
18}
19
20void *Thread1(void *x) {
21  static Cache *c = CreateCache();
22  if (c->x == g_other)
23    exit(1);
24  return 0;
25}
26
27int main() {
28  pthread_t t[2];
29  pthread_create(&t[0], 0, Thread1, 0);
30  pthread_create(&t[1], 0, Thread1, 0);
31  pthread_join(t[0], 0);
32  pthread_join(t[1], 0);
33}
34
35// CHECK-NOT: WARNING: ThreadSanitizer: data race
36