summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/tiny_race.c
blob: c10eab15c5a9806b7f05c6da7550da066bd1ad79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
#include <pthread.h>
#include <unistd.h>

int Global;

void *Thread1(void *x) {
  sleep(1);
  Global = 42;
  return x;
}

int main() {
  pthread_t t;
  pthread_create(&t, 0, Thread1, 0);
  Global = 43;
  pthread_join(t, 0);
  return Global;
}

// CHECK: WARNING: ThreadSanitizer: data race
OpenPOWER on IntegriCloud