1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
---|---|
2 | #include "test.h" |
3 | |
4 | volatile int X; |
5 | |
6 | void *Thread1(void *x) { |
7 | barrier_wait(barrier: &barrier); |
8 | X = 42; |
9 | X = 66; |
10 | X = 78; |
11 | return 0; |
12 | } |
13 | |
14 | void *Thread2(void *x) { |
15 | X = 11; |
16 | X = 99; |
17 | X = 73; |
18 | barrier_wait(barrier: &barrier); |
19 | return 0; |
20 | } |
21 | |
22 | int main() { |
23 | barrier_init(barrier: &barrier, count: 2); |
24 | pthread_t t; |
25 | pthread_create(newthread: &t, attr: 0, start_routine: Thread1, arg: 0); |
26 | Thread2(x: 0); |
27 | pthread_join(th: t, thread_return: 0); |
28 | } |
29 | |
30 | // CHECK: ThreadSanitizer: reported 1 warnings |
31 |