[libcxx-commits] [libcxx] [libc++][C++03] cherry-pick #128054 (PR #156672)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 3 06:55:09 PDT 2025


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/156672

None

>From d202114bf682971cd4cbcb15ffb2f3bad2d6050b Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 3 Sep 2025 15:51:55 +0200
Subject: [PATCH] [libc++][C++03] cherry-pick #128054

---
 libcxx/include/__cxx03/__mutex/once_flag.h                   | 5 +++--
 .../thread.once/thread.once.callonce/call_once.pass.cpp      | 2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/__cxx03/__mutex/once_flag.h b/libcxx/include/__cxx03/__mutex/once_flag.h
index eaeaa6121bff8..529aa77071776 100644
--- a/libcxx/include/__cxx03/__mutex/once_flag.h
+++ b/libcxx/include/__cxx03/__mutex/once_flag.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___CXX03___MUTEX_ONCE_FLAG_H
 
 #include <__cxx03/__config>
+#include <__cxx03/__memory/addressof.h>
 #include <__cxx03/__memory/shared_ptr.h> // __libcpp_acquire_load
 #include <__cxx03/__tuple/tuple_indices.h>
 #include <__cxx03/__tuple/tuple_size.h>
@@ -82,7 +83,7 @@ template <class _Callable>
 inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) {
   if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
     __call_once_param<_Callable> __p(__func);
-    std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
+    std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<_Callable>));
   }
 }
 
@@ -90,7 +91,7 @@ template <class _Callable>
 inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) {
   if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
     __call_once_param<const _Callable> __p(__func);
-    std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
+    std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<const _Callable>));
   }
 }
 
diff --git a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
index ea5b63d2804a1..121705f2e3a99 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -8,8 +8,6 @@
 
 // UNSUPPORTED: no-threads
 
-// XFAIL: FROZEN-CXX03-HEADERS-FIXME
-
 // <mutex>
 
 // struct once_flag;



More information about the libcxx-commits mailing list