https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105880
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Sebastian Huber from comment #1) > Just for reference, the destructor code is (eh_globals.cc): > > struct __eh_globals_init > { > __gthread_key_t _M_key; > bool _M_init; > > [...] > > ~__eh_globals_init() > { > if (_M_init) > __gthread_key_delete(_M_key); > _M_init = false; <-- This store is optimized away > } > }; Because it is dead after the deconstruct is called. What is the full sequence is there another constructor being called after exit? Or something else?