blob: c185623ff5ca023dadc16d5eeaadd7c5acca9c44 [file] [log] [blame]
Dmitry Vyukov368d97e2013-04-24 11:16:47 +00001// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2#include <pthread.h>
3#include <unistd.h>
4
5_Atomic(int*) p;
6
7void *thr(void *a) {
8 sleep(1);
9 int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED);
10 *pp = 42;
11 return 0;
12}
13
14int main() {
15 pthread_t th;
16 pthread_create(&th, 0, thr, p);
17 __c11_atomic_store(&p, new int, __ATOMIC_RELAXED);
18 pthread_join(th, 0);
19}
20
21// CHECK: data race
22// CHECK: Previous write
23// CHECK: #0 operator new
24// CHECK: Location is heap block
25// CHECK: #0 operator new