Skip to content

Commit 32546c3

Browse files
committed
avoid symmetric transfer on GCC
1 parent 524da12 commit 32546c3

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ function(def_example example)
3232
PRIVATE STDEXEC::stdexec
3333
stdexec_executable_flags
3434
$<TARGET_NAME_IF_EXISTS:TBB::tbb>)
35+
target_compile_options(${target} INTERFACE
36+
$<$<CXX_COMPILER_ID:GNU>:-Wno-maybe-uninitialized>) # warnings being emitted from stdlib headers, why?
3537
endfunction()
3638

3739
set(stdexec_examples

include/stdexec/__detail/__as_awaitable.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <functional> // for std::identity
3434
#include <system_error>
3535
#include <thread>
36-
#include <variant>
3736

3837
STDEXEC_PRAGMA_PUSH()
3938
STDEXEC_PRAGMA_IGNORE_GNU("-Wmissing-braces")
@@ -307,8 +306,7 @@ namespace STDEXEC
307306
}
308307

309308
constexpr auto
310-
await_suspend([[maybe_unused]] __std::coroutine_handle<_Promise> __hcoro) noexcept //
311-
-> __std::coroutine_handle<>
309+
await_suspend([[maybe_unused]] __std::coroutine_handle<_Promise> __hcoro) noexcept -> bool
312310
{
313311
STDEXEC_ASSERT(this->__continuation_ == __hcoro);
314312

@@ -330,14 +328,14 @@ namespace STDEXEC
330328
// The operation completed inline with set_value or set_error, so we can just
331329
// resume the current coroutine. await_resume will either return the value or
332330
// throw as appropriate.
333-
return __hcoro;
331+
return false;
334332
}
335333
else
336334
{
337335
// If __ready_ was still false when executing the CAS, then the operation did not
338336
// complete inline. The continuation will be resumed when the operation
339337
// completes, so we return a noop_coroutine to suspend the current coroutine.
340-
return __std::noop_coroutine();
338+
return true;
341339
}
342340
}
343341

@@ -363,7 +361,7 @@ namespace STDEXEC
363361
{}
364362

365363
auto await_suspend([[maybe_unused]] __std::coroutine_handle<_Promise> __hcoro)
366-
-> __std::coroutine_handle<>
364+
-> STDEXEC_PP_IF(STDEXEC_GCC(), bool, __std::coroutine_handle<>)
367365
{
368366
STDEXEC_ASSERT(this->__continuation_ == __hcoro);
369367
{
@@ -379,14 +377,16 @@ namespace STDEXEC
379377
// unhandled_stopped() on the promise to propagate the stop signal. That will
380378
// result in the coroutine being torn down, so beware. We then resume the
381379
// returned coroutine handle (which may be a noop_coroutine).
382-
return __hcoro.promise().unhandled_stopped();
380+
return STDEXEC_PP_IF(STDEXEC_GCC(),
381+
(__hcoro.promise().unhandled_stopped().resume(), true),
382+
__hcoro.promise().unhandled_stopped());
383383
}
384384
else
385385
{
386386
// The operation completed with set_value or set_error, so we can just resume
387387
// the current coroutine. await_resume will either return the value or throw as
388388
// appropriate.
389-
return __hcoro;
389+
return STDEXEC_PP_IF(STDEXEC_GCC(), false, __hcoro);
390390
}
391391
}
392392

include/stdexec/__detail/__task.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,17 @@ namespace STDEXEC
252252
return __attrs{};
253253
}
254254

255+
#if !STDEXEC_GCC()
256+
// This transforms a task into an __awaiter that can perform symmetric transfer when
257+
// co_awaited. It is disabled on GCC due to
258+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94794, which causes unbounded stack
259+
// growth.
255260
template <class _ParentPromise>
256261
constexpr auto as_awaitable(_ParentPromise& __parent) && noexcept
257262
{
258263
return __awaiter<_ParentPromise>(static_cast<task&&>(*this), __parent);
259264
}
265+
#endif
260266

261267
private:
262268
using __on_stopped_t = __forward_stop_request<stop_source_type>;

test/stdexec/types/test_task.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ namespace
244244
CHECK(i == 42);
245245
}
246246

247-
# if !STDEXEC_GCC() || (STDEXEC_GCC_VERSION >= 13'00 && defined(__OPTIMIZE__))
248-
// This test is disabled on GCC due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94794
249-
250247
auto sync() -> ex::task<int>
251248
{
252249
co_return 42;
@@ -281,8 +278,6 @@ namespace
281278
CHECK(i == 84'000'042);
282279
}
283280

284-
# endif
285-
286281
// FUTURE TODO: add support so that `co_await sndr` can return a reference.
287282
// auto test_task_awaits_just_ref_sender() -> ex::task<void> {
288283
// int value = 42;

0 commit comments

Comments
 (0)