llvm-project
24 строки · 477.0 Байт
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"3#include <pthread.h>4#include <stdio.h>5#include <stddef.h>6
7void *Thread(void *a) {8((int*)a)[0]++;9barrier_wait(&barrier);10return NULL;11}
12
13int main() {14barrier_init(&barrier, 2);15int *p = new int(42);16pthread_t t;17pthread_create(&t, NULL, Thread, p);18barrier_wait(&barrier);19p[0]++;20pthread_join(t, NULL);21delete p;22}
23
24// CHECK: WARNING: ThreadSanitizer: data race
25