[libcxx-commits] [PATCH] D65667: [libcxx] Avoid destructor call for error_category singletons

Chris Bowler via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 28 10:04:58 PST 2022


cebowleratibm added a comment.

This patch has sat idle for 2+ years but I think the current patch is an improvement.  Currently, the error_category singletons are implemented as static locals for which there is no guarantee that the destructors won't run prematurely.  The proposed patch fixes that problem.

Perhaps it is desirable to coalesce these singletons to static globals in a single module but there appears to be contention on the thread as to whether or not that is desirable.  The static local solution has the advantage that it does not cause initialization if it is unused, but the accessor functions will be slower.  My suggestion is to commit this patch and if anyone feels it's important to move to file scope globals then that can be addressed in a future patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65667/new/

https://reviews.llvm.org/D65667



More information about the libcxx-commits mailing list