public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66967] New: thread local's destructor not called if compile with -fno-use-cxa-atexit
@ 2015-07-22 12:40 zhykzhykzhyk at gmail dot com
  0 siblings, 0 replies; only message in thread
From: zhykzhykzhyk at gmail dot com @ 2015-07-22 12:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66967

            Bug ID: 66967
           Summary: thread local's destructor not called if compile with
                    -fno-use-cxa-atexit
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhykzhykzhyk at gmail dot com
  Target Milestone: ---

$ cat a.cc
#include <cstdio>
#include <thread>

struct A {
  A() { puts("CONS"); }
  ~A() { puts("DES"); }
};

static thread_local A a;

int main() {
  std::thread t1([]{ a; });
  t1.join();
  puts("X");
  std::thread t2([]{ a; });
  t2.join();
}
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/zhyk/gcc5-install/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/home/zhyk/gcc5-install
--disable-multilib
Thread model: posix
gcc version 5.2.0 (GCC)
$ g++ -std=c++14 -fno-use-cxa-atexit a.cc -lpthread
$ ./a.out
CONS
X
CONS

Expected output:
CONS
DES
X
CONS
DES


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-22 12:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-22 12:40 [Bug c++/66967] New: thread local's destructor not called if compile with -fno-use-cxa-atexit zhykzhykzhyk at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).