1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
2 | #include "test.h" |
3 | |
4 | int X = 0; |
5 | |
6 | void *Thread(void *p) { |
7 | X = 42; |
8 | barrier_wait(barrier: &barrier); |
9 | return 0; |
10 | } |
11 | |
12 | int main() { |
13 | barrier_init(barrier: &barrier, count: 2); |
14 | pthread_t t; |
15 | sleep(seconds: 1); // must not appear in the report |
16 | pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0); |
17 | barrier_wait(barrier: &barrier); |
18 | X = 43; |
19 | pthread_join(th: t, thread_return: 0); |
20 | return 0; |
21 | } |
22 | |
23 | // CHECK: WARNING: ThreadSanitizer: data race |
24 | // CHECK-NOT: As if synchronized via sleep |
25 | |