1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 struct P { 7 int x; 8 int y; 9 }; 10 Helper()11int Helper() { 12 try { 13 static int i = []() { 14 throw P{}; 15 return 1; 16 }(); 17 return i; 18 } catch (P) { 19 return 0; 20 } 21 } 22 Thread(void * x)23void *Thread(void *x) { 24 for (int i = 0; i < 1000; ++i) { 25 Helper(); 26 } 27 return 0; 28 } 29 main()30int main() { 31 pthread_t t[2]; 32 pthread_create(&t[0], 0, Thread, 0); 33 pthread_create(&t[1], 0, Thread, 0); 34 pthread_join(t[0], 0); 35 pthread_join(t[1], 0); 36 fprintf(stderr, "PASS\n"); 37 } 38 39 // CHECK-NOT: WARNING: ThreadSanitizer: data race 40