summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/lit_tests/atomic_free.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-02-01 14:41:58 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-02-01 14:41:58 +0000
commit87c6bb97162aaa9a9124f2af7dda411bac6f75fd (patch)
treee40feb4bd0da9c6e9c553bc44027d4654b364f2d /compiler-rt/lib/tsan/lit_tests/atomic_free.cc
parent36a6dd04eff1956a5f638d9860c32d930cd4c194 (diff)
downloadbcm5719-llvm-87c6bb97162aaa9a9124f2af7dda411bac6f75fd.tar.gz
bcm5719-llvm-87c6bb97162aaa9a9124f2af7dda411bac6f75fd.zip
tsan: even if races between atomic and plain memory accesses are turned off (report_atomic_races=0),
still report races between atomic accesses and free(). llvm-svn: 174175
Diffstat (limited to 'compiler-rt/lib/tsan/lit_tests/atomic_free.cc')
-rw-r--r--compiler-rt/lib/tsan/lit_tests/atomic_free.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/atomic_free.cc b/compiler-rt/lib/tsan/lit_tests/atomic_free.cc
new file mode 100644
index 00000000000..ba9bd5ac4ae
--- /dev/null
+++ b/compiler-rt/lib/tsan/lit_tests/atomic_free.cc
@@ -0,0 +1,19 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | 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
OpenPOWER on IntegriCloud