Fix bug in recursive_generator<T> when building under Clang.
The promise_type::get_return_object() method was returning a reference to the promise object, expecting that reference to be passed to the constructor of recursive_generator<T>. However, under Clang the result of get_return_object() is assigned to an 'auto' variable, which ends up taking a copy of the promise object on the stack and passing that copy into the recursive_generator<T> constructor. Modified get_return_object() to return the already-constructed recursive_generator<T> object.
This commit is contained in:
parent
1947c244e7
commit
e5bf85c5e9
|
@ -28,9 +28,12 @@ namespace cppcoro
|
|||
, m_parentOrLeaf(this)
|
||||
{}
|
||||
|
||||
promise_type& get_return_object() noexcept
|
||||
promise_type(const promise_type&) = delete;
|
||||
promise_type(promise_type&&) = delete;
|
||||
|
||||
auto get_return_object() noexcept
|
||||
{
|
||||
return *this;
|
||||
return recursive_generator<T>{ *this };
|
||||
}
|
||||
|
||||
std::experimental::suspend_always initial_suspend() noexcept
|
||||
|
|
Loading…
Reference in a new issue