[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / tls / thread_local4.C
blob24f2de6ff1cb4fbb0acd3c04b147c3c161c01644
1 // Test for cleanups with pthread_cancel.
3 // { dg-do run }
4 // { dg-require-effective-target c++11 }
5 // { dg-require-effective-target tls_runtime }
6 // { dg-require-effective-target pthread }
7 // { dg-require-effective-target non_bionic }
8 // { dg-options -pthread }
9 // { dg-add-options tls }
11 #include <pthread.h>
12 #include <unistd.h>
14 int c;
15 int d;
16 struct A
18   A() { ++c; }
19   ~A() { ++d; }
22 void f()
24   thread_local A a;
27 void *thread_main(void *)
29   f(); f(); f();
30   while (true)
31     {
32       pthread_testcancel();
33       sleep (1);
34     }
37 int main()
39   pthread_t thread;
40   pthread_create (&thread, 0, thread_main, 0);
41   pthread_cancel(thread);
42   pthread_join(thread, 0);
43   pthread_create (&thread, 0, thread_main, 0);
44   pthread_cancel(thread);
45   pthread_join(thread, 0);
47    if (c != 2 || d != 2)
48      __builtin_abort();