1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
2 // Race between an aligned access and an unaligned access, which
3 // touches the same memory region.
9 void *Thread1(void *x
) {
11 barrier_wait(&barrier
);
15 void *Thread2(void *x
) {
16 barrier_wait(&barrier
);
17 char *p1
= reinterpret_cast<char *>(&Global
[0]);
18 struct __attribute__((packed
, aligned(1))) u_uint64_t
{ uint64_t val
; };
19 u_uint64_t
*p4
= reinterpret_cast<u_uint64_t
*>(p1
+ 1);
25 barrier_init(&barrier
, 2);
27 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
28 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
29 pthread_join(t
[0], NULL
);
30 pthread_join(t
[1], NULL
);
31 fprintf(stderr
, "Pass\n");
32 // CHECK: ThreadSanitizer: data race