111
|
1 // Test for cleanups in the main thread without -pthread.
|
|
2
|
|
3 /* wrapping doesn't reflect _exit value */
|
|
4 // { dg-do run { target { c++11 && unwrapped } } }
|
|
5 // { dg-add-options tls }
|
|
6 // { dg-require-effective-target tls_runtime }
|
|
7
|
|
8 extern "C" void _exit (int);
|
|
9
|
|
10 int c;
|
|
11 struct A
|
|
12 {
|
|
13 A() { ++c; }
|
|
14 ~A() { if (c == 1) _exit(0); }
|
|
15 };
|
|
16
|
|
17 void f()
|
|
18 {
|
|
19 thread_local A a;
|
|
20 }
|
|
21
|
|
22 void *thread_main(void *)
|
|
23 {
|
|
24 f(); f(); f();
|
131
|
25 return 0;
|
111
|
26 }
|
|
27
|
|
28 int main()
|
|
29 {
|
|
30 thread_main(0);
|
|
31
|
|
32 // The dtor for a in the main thread is run after main exits, so we
|
|
33 // return 1 now and override the return value with _exit above.
|
|
34 return 1;
|
|
35 }
|