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 { AA13 A() { ++c; } ~AA14 ~A() { ++d; } 15 }; 16 17 thread_local A a; 18 thread_main(void *)19void *thread_main(void *) 20 { 21 A* ap = &a; 22 return 0; 23 } 24 25 #include <pthread.h> 26 main()27int 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 } 38