1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
4 void *Thread1(void *x) {
5 barrier_wait(&barrier);
11 void *Thread2(void *x) {
14 barrier_wait(&barrier);
19 barrier_init(&barrier, 2);
20 int *data = new int(42);
21 print_address("ptr1=", 1, data);
22 print_address("ptr2=", 1, (char*)data + 2);
24 pthread_create(&t[0], NULL, Thread1, data);
25 pthread_create(&t[1], NULL, Thread2, data);
26 pthread_join(t[0], NULL);
27 pthread_join(t[1], NULL);
31 // CHECK: ptr1=[[PTR1:0x[0-9,a-f]+]]
32 // CHECK: ptr2=[[PTR2:0x[0-9,a-f]+]]
33 // CHECK: WARNING: ThreadSanitizer: data race
34 // CHECK: Write of size 4 at [[PTR1]] by thread T1:
35 // CHECK: Previous write of size 1 at [[PTR2]] by thread T2: