NVIDIA / NVIDIA/stdexec

Helper __awaitable concept doesn't correctly handle await_transform

Open
#596 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
C++
Stars
2.4k
Forks
270
Avg merge
3d 6h
Merged PRs (30d)
39

Description

The coroutine semantics are such that if there is any member of the promise type declared as await_transform then the co_await expression inside a coroutine with that promise type will first call promise.await_transform().

The current concept just checks that the particular type being queried is callable with promise.await_transform(<expr>) and if that is not well-formed then it falls back to just checking if <expr> has a valid operator co_await().

This could result in incorrectly reporting that a type satisfies __awaitable<Promise> when a co_await expression with an operand of that type would be ill-formed.

e.g. The current logic would indicate that std::suspend_always satisfies the __awaitable<std::generator<int>::promise_type> concept, despite co_await expressions being ill-formed inside std::generator coroutines.

Note that it's not currently possible to exactly match the behaviour of the compiler in library alone.
There would need to be some intrinsic for asking the compiler whether a given promise type has any member named 'await_transform' declared.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in include/coroutine.hpp around the __awaitable concept at the linked line, then compare its checks with the stated coroutine semantics and the std::generator promise_type example. Determine how the concept should account for a declared await_transform member and whether the required compiler intrinsic is available; done means the concept no longer reports invalid co_await expressions as awaitable.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.