https://bugs.kde.org/show_bug.cgi?id=392924

            Bug ID: 392924
           Summary: coroutine ts crash
           Product: kdevelop
           Version: git master
          Platform: Gentoo Packages
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Language Support: CPP (Clang-based)
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: edc0a91c24342ae88...@yandex.ru
  Target Milestone: ---

example from https://isocpp.org/files/papers/N4663.pdf


#include <experimental/coroutine>
#include <iostream>


struct generator {
  struct promise_type;
  using handle = std::experimental::coroutine_handle<promise_type>;
  struct promise_type {
    int current_value;
    static auto get_return_object_on_allocation_failure() {
      return generator{nullptr};
    }
    auto get_return_object() {
      return generator{handle::from_promise(*this)};
    }
    auto initial_suspend() {
      return std::experimental::suspend_always{};
    }
    auto final_suspend() {
      return std::experimental::suspend_always{};
    }
    auto yield_value(int value) {
      current_value = value;
      return std::experimental::suspend_always{};
    }
    void unhandled_exception() { std::terminate(); }
//     void return_void() {}// uncomment -> crash

  };
  bool move_next() {
    return coro ? (coro.resume(), !coro.done()) : false;
  }
  int current_value() {
    return coro.promise().current_value;
  }
  ~generator() {
    if(coro) coro.destroy();
  }
private:
  generator(handle h) : coro(h) {}
  handle coro;
};

generator f() {
  co_yield 1;
  co_yield 2;
}

int main() {
  auto g = f();

  while(g.move_next()) std::cout << g.current_value() << std::endl;
}


Also, crash on all other examples. The compilation passes normally.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to