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