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