28 lines · cpp
1// RUN: %clangxx_tsan -O1 -fno-inline-functions %s -o %t && %deflake %run %t | FileCheck %s2#include "test.h"3#include <memory>4 5std::unique_ptr<long> global(new long(42));6 7void *thread(void *x) {8 *global = 43;9 barrier_wait(&barrier);10 return nullptr;11}12 13int main() {14 barrier_init(&barrier, 2);15 pthread_t th;16 pthread_create(&th, nullptr, thread, nullptr);17 pthread_detach(th);18 barrier_wait(&barrier);19 return 0;20}21 22// CHECK: WARNING: ThreadSanitizer: data race23// CHECK: Write of size 824// The exact spelling and number of std frames is hard to guess.25// CHECK: unique_ptr26// CHECK: #{{[1-9]}} cxa_at_exit_callback_installed_at27// CHECK: #{{[2-9]}} __cxx_global_var_init28