2014-05-30 22:08:51 +08:00
|
|
|
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
2015-05-15 04:27:12 +08:00
|
|
|
#include "test.h"
|
2012-05-10 22:18:22 +08:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
void *Thread(void *a) {
|
|
|
|
((int*)a)[0]++;
|
2015-05-15 04:27:12 +08:00
|
|
|
barrier_wait(&barrier);
|
2012-05-10 22:18:22 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2015-05-15 04:27:12 +08:00
|
|
|
barrier_init(&barrier, 2);
|
2012-05-10 22:18:22 +08:00
|
|
|
int *p = new int(42);
|
|
|
|
pthread_t t;
|
|
|
|
pthread_create(&t, NULL, Thread, p);
|
2015-05-15 04:27:12 +08:00
|
|
|
barrier_wait(&barrier);
|
2012-05-10 22:18:22 +08:00
|
|
|
p[0]++;
|
|
|
|
pthread_join(t, NULL);
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|