init-order-pthread-create.cc revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
1// Check that init-order checking is properly disabled if pthread_create is
2// called.
3
4// RUN: %clangxx_asan %s %p/Helpers/init-order-pthread-create-extra.cc -lpthread -o %t
5// RUN: env ASAN_OPTIONS=strict_init_order=true %run %t
6
7#include <stdio.h>
8#include <pthread.h>
9
10void *run(void *arg) {
11  return arg;
12}
13
14void *foo(void *input) {
15  pthread_t t;
16  pthread_create(&t, 0, run, input);
17  void *res;
18  pthread_join(t, &res);
19  return res;
20}
21
22void *bar(void *input) {
23  return input;
24}
25
26void *glob = foo((void*)0x1234);
27extern void *glob2;
28
29int main() {
30  printf("%p %p\n", glob, glob2);
31  return 0;
32}
33