[libcxx-commits] [libcxx] [libc++] Prevent ADL on _Block_copy/_Block_release (PR #179614)

Fady Farag via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 3 22:07:11 PST 2026


https://github.com/iidmsa created https://github.com/llvm/llvm-project/pull/179614

Suppress ADL on Blocks runtime calls in std::function by wrapping function names in parentheses.

>From c579cd0f9d96c11d8433ad7c40429fc888ae6f7e Mon Sep 17 00:00:00 2001
From: Fady Farag <com.webkit.iidmsa at gmail.com>
Date: Wed, 4 Feb 2026 00:01:04 -0600
Subject: [PATCH] [libc++] Prevent ADL on _Block_copy/_Block_release

Suppress ADL on Blocks runtime calls in std::function by wrapping
function names in parentheses.
---
 libcxx/include/__functional/function.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index 121417f90ff01..7576350fdea9e 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -540,7 +540,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_Ar
 #    if __has_feature(objc_arc)
       : __f_(__f)
 #    else
-      : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
+      : __f_(reinterpret_cast<__block_type>(__f ? (_Block_copy)(__f) : nullptr))
 #    endif
   {
   }
@@ -563,7 +563,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_Ar
   _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
 #    if !__has_feature(objc_arc)
     if (__f_)
-      _Block_release(__f_);
+      (_Block_release)(__f_);
 #    endif
     __f_ = 0;
   }



More information about the libcxx-commits mailing list