brintos

brintos / llvm-project-archived public Read only

0
0
Text · 573 B · f0c6f93 Raw
27 lines · cpp
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s2#include "test.h"3 4_Atomic(int*) p;5 6void *thr(void *a) {7  barrier_wait(&barrier);8  int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED);9  *pp = 42;10  return 0;11}12 13int main() {14  barrier_init(&barrier, 2);15  pthread_t th;16  pthread_create(&th, 0, thr, p);17  __c11_atomic_store(&p, new int, __ATOMIC_RELAXED);18  barrier_wait(&barrier);19  pthread_join(th, 0);20}21 22// CHECK: data race23// CHECK:   Previous write24// CHECK:     #0 operator new25// CHECK:   Location is heap block26// CHECK:     #0 operator new27