llvm-project/compiler-rt/lib/tsan/lit_tests/tiny_race.c

16 lines
322 B
C

// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
int Global;
void *Thread1(void *x) {
Global = 42;
return x;
}
int main() {
pthread_t t;
pthread_create(&t, NULL, Thread1, NULL);
Global = 43;
pthread_join(t, NULL);
return Global;
}
// CHECK: WARNING: ThreadSanitizer: data race