[llvm-bugs] [Bug 42107] New: coroutine_traits on lambda without state

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 3 00:31:53 PDT 2019


            Bug ID: 42107
           Summary: coroutine_traits on lambda without state
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: adi at thingdust.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hi. I'm not sure what the standard does say about this, but to me it sounds
like a bug.

The following code should work in my opinion (on godbolt:
  #include <experimental/coroutine>

  template <typename T>
  struct task {};

  template <typename Ret, typename... Args>
  struct std::experimental::coroutine_traits<task<Ret>, Args...> {
    static_assert(sizeof...(Args) == 0);

    struct promise_type {
        std::experimental::suspend_never initial_suspend() { return {}; }
        std::experimental::suspend_never final_suspend() { return {}; }
        void return_void() { }
        task<Ret> get_return_object(){ return {}; }
        void unhandled_exception(){ std::terminate(); }

  task<void> foo() {

  int main() {
      //does not work:
      auto bar = []() -> task<void> {

The background is that I am trying to differentiate between "safe" coroutines
(coroutines which cannot hold state from the caller: this ptr, reference
parameters, ...) and "unsafe" coroutines (free functions with only value

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190603/0276aa57/attachment.html>

More information about the llvm-bugs mailing list