[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / race_on_speculative_load.cc
blob31f0e4f2a31f4c8120604d4ae2006fd2d9ca4f47
1 // RUN: %clangxx_tsan -O1 %s -o %t && %t | FileCheck %s
2 // Regtest for https://code.google.com/p/thread-sanitizer/issues/detail?id=40
3 // This is a correct program and tsan should not report a race.
4 #include <pthread.h>
5 #include <unistd.h>
6 #include <stdio.h>
7 int g;
8 __attribute__((noinline))
9 int foo(int cond) {
10 if (cond)
11 return g;
12 return 0;
14 void *Thread1(void *p) {
15 long res = foo((long)p);
16 sleep(1);
17 return (void*) res;
20 int main() {
21 pthread_t t;
22 pthread_create(&t, 0, Thread1, 0);
23 g = 1;
24 pthread_join(t, 0);
25 printf("PASS\n");
26 // CHECK: PASS