[libcxx-commits] [libcxxabi] [libc++abi] Make once_flag constinit in cxa_exception_storage (PR #124627)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 27 13:07:11 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxxabi

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

This makes it clearer that initialization of this global variable is taking place at compile-time, reducing the likelihood of static initialization order fiasco.

---
Full diff: https://github.com/llvm/llvm-project/pull/124627.diff


1 Files Affected:

- (modified) libcxxabi/src/cxa_exception_storage.cpp (+1-1) 


``````````diff
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index 733f0d470569a2..05da6a48e313cf 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -56,7 +56,7 @@ extern "C" {
 namespace __cxxabiv1 {
 namespace {
     std::__libcpp_tls_key key_;
-    std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
+    constinit std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
 
     void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
         __free_with_fallback(p);

``````````

</details>


https://github.com/llvm/llvm-project/pull/124627


More information about the libcxx-commits mailing list