| 1 |
#include <pthread.h> |
| 2 |
#include <stdio.h> |
| 3 |
|
| 4 |
extern "C" const char *__tsan_default_options() { |
| 5 |
return "report_bugs=0"; |
| 6 |
} |
| 7 |
|
| 8 |
int Global; |
| 9 |
|
| 10 |
void *Thread1(void *x) { |
| 11 |
Global = 42; |
| 12 |
return NULL; |
| 13 |
} |
| 14 |
|
| 15 |
void *Thread2(void *x) { |
| 16 |
Global = 43; |
| 17 |
return NULL; |
| 18 |
} |
| 19 |
|
| 20 |
int main() { |
| 21 |
pthread_t t[2]; |
| 22 |
pthread_create(&t[0], NULL, Thread1, NULL); |
| 23 |
pthread_create(&t[1], NULL, Thread2, NULL); |
| 24 |
pthread_join(t[0], NULL); |
| 25 |
pthread_join(t[1], NULL); |
| 26 |
fprintf(stderr, "DONE\n"); |
| 27 |
return 0; |
| 28 |
} |
| 29 |
|
| 30 |
/* { dg-prune-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */ |
| 31 |
/* { dg-output "DONE" } */ |