https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102528
Bug ID: 102528
Summary: Unable to inline even trivial coroutines
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redbeard0531 at gmail dot com
Target Milestone: ---
https://godbolt.org/z/aoab9W4xG
This should all compile away, and test() should just be a single ret
instruction. That is not what happens now, even with -O3.
#include <coroutine>
struct simple {
struct promise_type {
void return_void() {}
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() { throw; }
simple get_return_object() { return {}; }
};
std::true_type await_ready() { return {}; }
void await_suspend(std::coroutine_handle<>) {}
void await_resume();
};
inline simple test1() {
co_return;
}
inline simple test2() {
co_await test1();
co_return;
}
void test() {
test2();
}