1 /* { dg-shouldfail "tsan" } */
2 /* { dg-additional-options "-ldl" } */
7 #include "tsan_barrier.h"
9 static pthread_barrier_t barrier;
12 void *Thread1(void *x) {
13 barrier_wait(&barrier);
18 void *Thread2(void *x) {
19 char *p1 = reinterpret_cast<char *>(&Global[0]);
20 struct __attribute__((packed, aligned(1))) u_uint64_t { uint64_t val; };
21 u_uint64_t *p4 = reinterpret_cast<u_uint64_t *>(p1 + 1);
23 barrier_wait(&barrier);
28 barrier_init(&barrier, 2);
30 pthread_create(&t[0], NULL, Thread1, NULL);
31 pthread_create(&t[1], NULL, Thread2, NULL);
32 pthread_join(t[0], NULL);
33 pthread_join(t[1], NULL);
34 fprintf(stderr, "Pass\n");
35 /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */
36 /* { dg-output "Pass.*" } */