https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118811
--- Comment #24 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:3a8d05b61a9568d60ee922f899408555470eeff1 commit r14-11367-g3a8d05b61a9568d60ee922f899408555470eeff1 Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Feb 12 17:29:59 2025 +0000 libstdc++: Use init_priority attribute for tzdb globals [PR118811] When linking statically to libstdc++.a (or to libstdc++_nonshared.a in the RHEL devtoolset compiler) there's a static initialization order problem where user code might be constructed before the std::chrono::tzdb_list globals, and so might try to use them after they've already been destroyed. Use the init_priority attribute on those globals so that they are initialized early. Since r15-7511-g4e7f74225116e7 we can disable the warnings for using a reserved priority using a diagnostic pragma. However, for the backport to the release branch the warnings can only be suppressed by defining the objects in a system header. Move them to a new file that uses '#pragma GCC system_header' and then include that in tzdb.cc. libstdc++-v3/ChangeLog: PR libstdc++/118811 * src/c++20/tzdb.cc (tzdb_list::_Node): Move definitions of static data members to new header. * src/c++20/tzdb_globals.h: New header. Use init_priority attribute on static data members. * testsuite/std/time/tzdb_list/pr118811.cc: New test. (cherry picked from commit 99f57446e63b8ebeaeeae8dc48981cd5f1dfb831)