]> git.proxmox.com Git - rustc.git/blame - src/llvm/projects/compiler-rt/lib/tsan/lit_tests/heap_race.cc
Imported Upstream version 0.6
[rustc.git] / src / llvm / projects / compiler-rt / lib / tsan / lit_tests / heap_race.cc
CommitLineData
223e47cc
LB
1// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2#include <pthread.h>
3#include <stdio.h>
4#include <stddef.h>
5
6void *Thread(void *a) {
7 ((int*)a)[0]++;
8 return NULL;
9}
10
11int main() {
12 int *p = new int(42);
13 pthread_t t;
14 pthread_create(&t, NULL, Thread, p);
15 p[0]++;
16 pthread_join(t, NULL);
17 delete p;
18}
19
20// CHECK: WARNING: ThreadSanitizer: data race