diff --git a/include/stdexec/__detail/__bulk.hpp b/include/stdexec/__detail/__bulk.hpp index 73a2a7f4d..337af080e 100644 --- a/include/stdexec/__detail/__bulk.hpp +++ b/include/stdexec/__detail/__bulk.hpp @@ -281,7 +281,10 @@ namespace STDEXEC STDEXEC_TRY { - __state.__data_.__fun_(__shape_t(), __shape_t(__state.__data_.__shape_), __args...); + if (__shape_t{} < __state.__data_.__shape_) + { + __state.__data_.__fun_(__shape_t(), __shape_t(__state.__data_.__shape_), __args...); + } STDEXEC::set_value(static_cast<_State&&>(__state).__rcvr_, static_cast<_Args&&>(__args)...); } diff --git a/test/stdexec/algos/adaptors/test_bulk.cpp b/test/stdexec/algos/adaptors/test_bulk.cpp index 4ef06f697..c365e31ad 100644 --- a/test/stdexec/algos/adaptors/test_bulk.cpp +++ b/test/stdexec/algos/adaptors/test_bulk.cpp @@ -701,6 +701,26 @@ namespace ex::start(op); } + TEST_CASE("bulk_chunked function is not called with a zero shape", "[adaptors][bulk]") + { + int called{}; + + auto snd = ex::just() | ex::bulk_chunked(ex::seq, 0, [&called](int, int) { called++; }); + ex::sync_wait(std::move(snd)); + + CHECK(called == 0); + } + + TEST_CASE("bulk_chunked function is not called with a negative shape", "[adaptors][bulk]") + { + int called{}; + + auto snd = ex::just() | ex::bulk_chunked(ex::seq, -1, [&called](int, int) { called++; }); + ex::sync_wait(std::move(snd)); + + CHECK(called == 0); + } + TEST_CASE("bulk_unchunked function in not called on stop", "[adaptors][bulk]") { constexpr int n = 2;