summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/g++.dg/tls/thread_local2g.C
blob: 8304a4d2f931e946773b2fd6c0a8ca2c6d1dfc0f (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
// { dg-do run { target c++11 } }
// { dg-add-options tls }
// { dg-require-effective-target tls_runtime }

extern "C" void abort();

struct A
{
  A();
  int i;
};

thread_local A a;

A &f()
{
  return a;
}

int j;
A::A(): i(j) { }

int main()
{
  j = 42;
  if (f().i != 42)
    abort ();
}
OpenPOWER on IntegriCloud