From a03ebebd8d1e2764ed8be61a848b18a379398cc9 Mon Sep 17 00:00:00 2001 From: Ian Petersen Date: Wed, 27 May 2026 20:19:49 -0700 Subject: [PATCH 1/3] Give struct __rcvr user-defined ctors in __basic_sender This looks like it fixes a miscompilation leading to UB in combinations of `read_env` and `write_env` in Apple Clang. --- include/stdexec/__detail/__basic_sender.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/stdexec/__detail/__basic_sender.hpp b/include/stdexec/__detail/__basic_sender.hpp index 59eb1448a..fc4ee0796 100644 --- a/include/stdexec/__detail/__basic_sender.hpp +++ b/include/stdexec/__detail/__basic_sender.hpp @@ -236,6 +236,16 @@ namespace STDEXEC using receiver_concept = receiver_tag; using __index_t = __msize_t<_Idx>; + STDEXEC_ATTRIBUTE(always_inline) + constexpr explicit __rcvr(_State& __state) noexcept + : __state_(__state) + {} + + STDEXEC_ATTRIBUTE(always_inline) + constexpr __rcvr(__rcvr const & __other) noexcept + : __state_(__other.__state_) + {} + template STDEXEC_ATTRIBUTE(always_inline) constexpr void set_value(_Args&&... __args) noexcept From e24ff03113a77d26eaf38cfc1cf5ac1709a6d168 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 28 May 2026 09:13:16 -0700 Subject: [PATCH 2/3] Update include/stdexec/__detail/__basic_sender.hpp --- include/stdexec/__detail/__basic_sender.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/stdexec/__detail/__basic_sender.hpp b/include/stdexec/__detail/__basic_sender.hpp index fc4ee0796..797aae1c7 100644 --- a/include/stdexec/__detail/__basic_sender.hpp +++ b/include/stdexec/__detail/__basic_sender.hpp @@ -236,6 +236,9 @@ namespace STDEXEC using receiver_concept = receiver_tag; using __index_t = __msize_t<_Idx>; + +#if STDEXEC_APPLE_CLANG() + // These constructors are a work-around for bad codegen with apple-clang STDEXEC_ATTRIBUTE(always_inline) constexpr explicit __rcvr(_State& __state) noexcept : __state_(__state) @@ -245,6 +248,7 @@ namespace STDEXEC constexpr __rcvr(__rcvr const & __other) noexcept : __state_(__other.__state_) {} +#endif // STDEXEC_APPLE_CLANG() template STDEXEC_ATTRIBUTE(always_inline) From 5b79d7cc973b9b4a1c9f336e079821c320c342e0 Mon Sep 17 00:00:00 2001 From: Ian Petersen Date: Thu, 28 May 2026 12:38:51 -0700 Subject: [PATCH 3/3] Fix clang-format --- include/stdexec/__detail/__basic_sender.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/stdexec/__detail/__basic_sender.hpp b/include/stdexec/__detail/__basic_sender.hpp index 797aae1c7..d64ba987b 100644 --- a/include/stdexec/__detail/__basic_sender.hpp +++ b/include/stdexec/__detail/__basic_sender.hpp @@ -236,7 +236,6 @@ namespace STDEXEC using receiver_concept = receiver_tag; using __index_t = __msize_t<_Idx>; - #if STDEXEC_APPLE_CLANG() // These constructors are a work-around for bad codegen with apple-clang STDEXEC_ATTRIBUTE(always_inline)