From 513285119a8cebe9bdd7665c0be81c9a09b9f9de Mon Sep 17 00:00:00 2001 From: Zhavoronkov Aleksei Date: Mon, 12 Oct 2026 16:36:24 +0300 Subject: [PATCH] Initialize stop-when's once-flag before the callbacks that use it __fused_token::callback_type declared __called_ after __cb1_ and __cb2_. If the first token is already stopped, __cb1_'s constructor invokes the callback, which reads and sets __called_ before its lifetime begins; the member initializer then stores false. Depending on the indeterminate value, the stop is skipped (and lost if the second token never stops) or the function runs a second time when the second token stops. The draft requires it to run at most once ([exec.stop.when]). Regression from 6720837 (#2234), which moved __called_ to the end. Signed-off-by: Zhavoronkov Aleksei --- include/stdexec/__detail/__stop_when.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/stdexec/__detail/__stop_when.hpp b/include/stdexec/__detail/__stop_when.hpp index abec35ec4..5b1c25110 100644 --- a/include/stdexec/__detail/__stop_when.hpp +++ b/include/stdexec/__detail/__stop_when.hpp @@ -121,9 +121,9 @@ namespace STDEXEC using __cb2_t = _Token2::template callback_type<__cb_t>; _Fn __fn_; + __std::atomic __called_{false}; __cb1_t __cb1_; __cb2_t __cb2_; - __std::atomic __called_{false}; }; _Token1 __tkn1_;