https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104872
--- Comment #2 from Benjamin Buch <benni.buch at gmail dot com> ---
To workaround it is enough define the wrapper constructor to build a string.
```cpp
wrapper(std::string text): filename(std::move(text)) {}
```
https://godbolt.org/z/9za7hfjs8
```cpp
#include <coroutine>
#include <iostream>
using namespace std::literals;
class logging_string{
public:
logging_string(std::string text): text_(std::move(text)) {
std::cout << " view: " << this << " " << text_ << std::endl;
}
logging_string(logging_string&& other) {
std::cout << " move: " << this << " <= " << &other << " new <= "
<< other.text_ << std::endl;
text_ = std::move(other.text_);
}
~logging_string(){
std::cout << " destruct: " << this << " " << text_ << std::endl;
}
logging_string& operator=(logging_string&& other){
std::cout << "move-assign: " << this << " <= " << &other << " " <<
text_ << " <= " << other.text_ << std::endl;
text_ = std::move(other.text_);
return *this;
}
private:
std::string text_;
};
struct wrapper{
// wrapper(std::string text): filename(std::move(text)) {}
logging_string filename;
};
struct generator{
struct promise_type;
using handle_type = std::coroutine_handle<promise_type>;
struct promise_type{
wrapper value{"default"s};
generator get_return_object(){
return handle_type::from_promise(*this);
}
std::suspend_always initial_suspend(){
return {};
}
std::suspend_always final_suspend()noexcept{
return {};
}
void unhandled_exception(){}
std::suspend_always yield_value(wrapper&& new_value){
value = std::move(new_value);
return {};
}
};
generator(handle_type h)
: handle(h)
{}
~generator(){
handle.destroy();
}
handle_type handle;
};
static generator generate(){
co_yield {"generate"s};
}
int main(){
auto gen = generate();
gen.handle();
}
```