]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/race_on_puts.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / tsan / race_on_puts.cc
CommitLineData
92a42be0
SL
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
3
4char s[] = "abracadabra";
5
6void *Thread0(void *p) {
7 puts(s);
8 barrier_wait(&barrier);
9 return 0;
10}
11
12void *Thread1(void *p) {
13 barrier_wait(&barrier);
14 s[3] = 'z';
15 return 0;
16}
17
18int main() {
19 barrier_init(&barrier, 2);
20 pthread_t th[2];
21 pthread_create(&th[0], 0, Thread0, 0);
22 pthread_create(&th[1], 0, Thread1, 0);
23 pthread_join(th[0], 0);
24 pthread_join(th[1], 0);
25 fprintf(stderr, "DONE");
26}
27
28// CHECK: WARNING: ThreadSanitizer: data race
29// CHECK: DONE
30