From edaea95a7aee1b6ee34208a273012e84cfa1b66a Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 24 May 2026 21:11:09 -0700 Subject: [PATCH 1/3] disable `at_coroutine_exit` on apple-clang because it generates bad code --- include/exec/at_coroutine_exit.hpp | 5 +++++ include/exec/task.hpp | 11 ++++++++++- test/exec/test_at_coroutine_exit.cpp | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/exec/at_coroutine_exit.hpp b/include/exec/at_coroutine_exit.hpp index 9a872f67f..6e38c85bd 100644 --- a/include/exec/at_coroutine_exit.hpp +++ b/include/exec/at_coroutine_exit.hpp @@ -25,6 +25,11 @@ #include #include +#if STDEXEC_APPLE_CLANG() +# error \ + "at_coroutine_exit is not supported on Apple Clang due to a compiler bug that causes use-after-scope." +#endif + namespace experimental::execution { namespace __at_coro_exit diff --git a/include/exec/task.hpp b/include/exec/task.hpp index d800318ca..1b0cbda61 100644 --- a/include/exec/task.hpp +++ b/include/exec/task.hpp @@ -28,10 +28,13 @@ #include "../stdexec/functional.hpp" #include "any_sender_of.hpp" -#include "at_coroutine_exit.hpp" #include "completion_behavior.hpp" #include "scope.hpp" +#if !STDEXEC_APPLE_CLANG() +# include "at_coroutine_exit.hpp" +#endif + STDEXEC_PRAGMA_PUSH() STDEXEC_PRAGMA_IGNORE_GNU("-Wundefined-inline") @@ -419,6 +422,7 @@ namespace experimental::execution __std::coroutine_handle<_Promise> __parent_; }; +#if !STDEXEC_APPLE_CLANG() template struct __reschedule_awaiter { @@ -491,6 +495,7 @@ namespace experimental::execution return {static_cast<_Scheduler&&>(__sched)}; } }; +#endif //////////////////////////////////////////////////////////////////////////////// // basic_task @@ -611,6 +616,7 @@ namespace experimental::execution } } +# if !STDEXEC_APPLE_CLANG() template requires __start_scheduler_provider<_Context> auto await_transform(__reschedule_coroutine_on_t::__wrapper<_Scheduler> __box) noexcept @@ -618,6 +624,7 @@ namespace experimental::execution { return __reschedule_awaiter<_Scheduler, __promise>{__box.__sched_}; } +# endif #endif template <__sender_adaptor_closure_for<__just_void<__scheduler_t>> _Closure> @@ -718,7 +725,9 @@ namespace experimental::execution template using task = basic_task<_Ty, default_task_context<_Ty>>; +#if !STDEXEC_APPLE_CLANG() inline constexpr __task::__reschedule_coroutine_on_t reschedule_coroutine_on{}; +#endif } // namespace experimental::execution namespace exec = experimental::execution; diff --git a/test/exec/test_at_coroutine_exit.cpp b/test/exec/test_at_coroutine_exit.cpp index a566856bf..65ef942d5 100644 --- a/test/exec/test_at_coroutine_exit.cpp +++ b/test/exec/test_at_coroutine_exit.cpp @@ -17,7 +17,7 @@ #include -#if !STDEXEC_NO_STDCPP_COROUTINES() && !STDEXEC_NO_STDCPP_EXCEPTIONS() +#if !STDEXEC_NO_STDCPP_COROUTINES() && !STDEXEC_NO_STDCPP_EXCEPTIONS() && !STDEXEC_APPLE_CLANG() # include # include # include From c21f826aad4b888481a1dfe179c9dc344e56d997 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 24 May 2026 21:25:24 -0700 Subject: [PATCH 2/3] disable coro reschedule tests on apple-clang --- test/exec/test_task.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/exec/test_task.cpp b/test/exec/test_task.cpp index e64e662a5..1a14a69be 100644 --- a/test/exec/test_task.cpp +++ b/test/exec/test_task.cpp @@ -49,6 +49,7 @@ namespace return thread_id; } +#if !STDEXEC_APPLE_CLANG() auto test_stickiness_for_two_single_thread_contexts_nested(ex::scheduler auto scheduler1, ex::scheduler auto, auto id1, @@ -210,6 +211,7 @@ namespace auto t = test_stickiness_for_two_single_thread_contexts(scheduler1, scheduler2, id1, id2); ex::sync_wait(std::move(t)); } +#endif auto test_stick_on_main_nested(ex::scheduler auto sched1, ex::scheduler auto, From 7da73cf33010cbd6ffcc351c078144a26f8d4cfa Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 25 May 2026 00:10:44 -0700 Subject: [PATCH 3/3] format --- test/exec/test_task.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/exec/test_task.cpp b/test/exec/test_task.cpp index 1a14a69be..9d2d6a137 100644 --- a/test/exec/test_task.cpp +++ b/test/exec/test_task.cpp @@ -49,7 +49,7 @@ namespace return thread_id; } -#if !STDEXEC_APPLE_CLANG() +# if !STDEXEC_APPLE_CLANG() auto test_stickiness_for_two_single_thread_contexts_nested(ex::scheduler auto scheduler1, ex::scheduler auto, auto id1, @@ -211,7 +211,7 @@ namespace auto t = test_stickiness_for_two_single_thread_contexts(scheduler1, scheduler2, id1, id2); ex::sync_wait(std::move(t)); } -#endif +# endif auto test_stick_on_main_nested(ex::scheduler auto sched1, ex::scheduler auto,