view gcc/testsuite/g++.dg/tls/thread_local6g.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Test for cleanups in the main thread without -pthread.

// { dg-do run { target c++11 } }
// { dg-add-options tls }
// { dg-require-effective-target unwrapped }
// { dg-require-effective-target tls_runtime }
// { dg-require-cxa-atexit "" }

extern "C" void _exit (int);

int c;
struct A
{
  A() { ++c; }
  ~A() { if (c == 1) _exit(0); }
};

thread_local A a;

void *thread_main(void *)
{
  A* ap = &a;
  return 0;
}

int main()
{
  thread_main(0);

  // The dtor for a in the main thread is run after main exits, so we
  // return 1 now and override the return value with _exit above.
  return 1;
}