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