comparison gcc/testsuite/g++.dg/tls/thread_local3g.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
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;
22 }
23
24 #include <pthread.h>
25
26 int main()
27 {
28 pthread_t thread;
29 pthread_create (&thread, 0, thread_main, 0);
30 pthread_join(thread, 0);
31 pthread_create (&thread, 0, thread_main, 0);
32 pthread_join(thread, 0);
33
34 if (c != 2 || d != 2)
35 __builtin_abort();
36 }