1// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
3
4int Global;
5
6void *Thread1(void *x) {
7 barrier_wait(barrier: &barrier);
8 Global = 42;
9 return x;
10}
11
12int main() {
13 barrier_init(barrier: &barrier, count: 2);
14 pthread_t t;
15 pthread_create(newthread: &t, attr: 0, start_routine: Thread1, arg: 0);
16 Global = 43;
17 barrier_wait(barrier: &barrier);
18 pthread_join(th: t, thread_return: 0);
19 return Global;
20}
21
22// CHECK: WARNING: ThreadSanitizer: data race
23

source code of compiler-rt/test/tsan/tiny_race.c