1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
10 void *MemCpyThread(void *a
) {
11 memcpy((int*)a
, z
, 16);
15 void *MemMoveThread(void *a
) {
16 memmove((int*)a
, z
, 16);
20 void *MemSetThread(void *a
) {
22 memset((int*)a
, 0, 16);
28 // Race on x between memcpy and memset
29 pthread_create(&t
[0], NULL
, MemCpyThread
, x
);
30 pthread_create(&t
[1], NULL
, MemSetThread
, x
);
31 pthread_join(t
[0], NULL
);
32 pthread_join(t
[1], NULL
);
33 // Race on y between memmove and memset
34 pthread_create(&t
[0], NULL
, MemMoveThread
, y
);
35 pthread_create(&t
[1], NULL
, MemSetThread
, y
);
36 pthread_join(t
[0], NULL
);
37 pthread_join(t
[1], NULL
);
43 // CHECK: WARNING: ThreadSanitizer: data race
45 // CHECK: #1 MemSetThread
46 // CHECK: Previous write
48 // CHECK: #1 MemCpyThread
50 // CHECK: WARNING: ThreadSanitizer: data race
52 // CHECK: #1 MemSetThread
53 // CHECK: Previous write
55 // CHECK: #1 MemMoveThread