aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c')
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c b/gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c
new file mode 100644
index 000000000..962497b28
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/tsan/tiny_race.c
@@ -0,0 +1,22 @@
+/* { dg-shouldfail "tsan" } */
+
+#include <pthread.h>
+#include <unistd.h>
+
+int Global;
+
+void *Thread1(void *x) {
+ sleep(1);
+ Global = 42;
+ return x;
+}
+
+int main() {
+ pthread_t t;
+ pthread_create(&t, 0, Thread1, 0);
+ Global = 43;
+ pthread_join(t, 0);
+ return Global;
+}
+
+/* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */