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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Fady Farag (iidmsa)

<details>
<summary>Changes</summary>

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

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


1 Files Affected:

- (modified) libcxx/include/__functional/function.h (+2-2) 


``````````diff
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;
   }

``````````

</details>


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


More information about the libcxx-commits mailing list