https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613
--- Comment #8 from Michal Zientkiewicz <michalz at nvidia dot com> --- Jakub: You read coorectly, I was checking for global construction/destruction order of many variables. I agree that a global lock is a heavy-handed solution - and likely the only one that would always guarantee destruction order. The example I posted is not very useful - the variables are independent. There are cases where moving atexit would help: Thread A Thread B acquire lock on S1 initialize S1 release lock on S1 acquire lock on S2 initialize S2, which depends on S1 S1 is seen as initialized -> proceed release lock on S2 atexit destroy S2 atexit destroy S1 Now we have reversed destruction order on _dependent_ variables and moving atexit inside the per-variable lock scope would fix the issue.