111
|
1 // { dg-do run }
|
|
2 // { dg-require-effective-target c++11 }
|
|
3 // { dg-require-effective-target tls_runtime }
|
|
4 // { dg-require-effective-target pthread }
|
|
5 // { dg-require-cxa-atexit "" }
|
|
6 // { dg-options -pthread }
|
|
7 // { dg-add-options tls }
|
|
8
|
|
9 int c;
|
|
10 int d;
|
|
11 struct A
|
|
12 {
|
|
13 A() { ++c; }
|
|
14 ~A() { ++d; }
|
|
15 };
|
|
16
|
|
17 thread_local A a;
|
|
18
|
|
19 void *thread_main(void *)
|
|
20 {
|
|
21 A* ap = &a;
|
131
|
22 return 0;
|
111
|
23 }
|
|
24
|
|
25 #include <pthread.h>
|
|
26
|
|
27 int main()
|
|
28 {
|
|
29 pthread_t thread;
|
|
30 pthread_create (&thread, 0, thread_main, 0);
|
|
31 pthread_join(thread, 0);
|
|
32 pthread_create (&thread, 0, thread_main, 0);
|
|
33 pthread_join(thread, 0);
|
|
34
|
|
35 if (c != 2 || d != 2)
|
|
36 __builtin_abort();
|
|
37 }
|