https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107500
--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to R. Diez from comment #16) > Therefore, variable "static __cxa_eh_globals eh_globals" in the past was > already initialised before any users (probably because static memory being > zeroed on start-up). The situation has not changed now. Now it's enforced by the compiler and will fail to compile if for some reason it can't be statically initialized. > This static variable already outlived anything else, as there was no > destructor changing anything on termination. Semantically, no, that's wrong. The C++ standard still says its lifetime ends, and the compiler can optimize based on that. It's storage is not reused, but its lifetime does end. But it also says the lifetime of the wrapper ends, so accessing eh_globals.obj is still semantically undefined. > Your patch introduced wrapper "struct constant_init" around it, which makes > GCC generate a constructor for the wrapper solely to register an empty > destructor with atexit(). Otherwise, the wrapper does nothing else useful. > > Your patch also changes '__eh_globals_init::_M_init' (a different global > object) to a static member. Is that not enough to fix the original problem? Yes, probably.