diff options
Diffstat (limited to 'test/tsan/atomic_free.cc')
-rw-r--r-- | test/tsan/atomic_free.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/tsan/atomic_free.cc b/test/tsan/atomic_free.cc new file mode 100644 index 000000000000..1dcf887c41d5 --- /dev/null +++ b/test/tsan/atomic_free.cc @@ -0,0 +1,19 @@ +// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s +#include <pthread.h> +#include <unistd.h> + +void *Thread(void *a) { + __atomic_fetch_add((int*)a, 1, __ATOMIC_SEQ_CST); + return 0; +} + +int main() { + int *a = new int(0); + pthread_t t; + pthread_create(&t, 0, Thread, a); + sleep(1); + delete a; + pthread_join(t, 0); +} + +// CHECK: WARNING: ThreadSanitizer: data race |