https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95822
Bug ID: 95822
Summary: [coroutines] compiler internal error with local object
with noexcept false destructor
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: victor.burckel at gmail dot com
Target Milestone: ---
It seems that when a coroutine contains a local object whose destructor is
marked as noexcept(false), gcc reaches an unexpected state and aborts.
When compiling the following code with gcc10.1.0 (-std=c++20 -fcoroutines), I
get a compiler internal error:
> internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:2830
Making the destructor noexcept fixes the error. I got the error when using
boost log within a couroutine. It uses a record_pump whose destructor is not
noexcept.
I managed to reproduce with godbolt (both gcc10.1 and gcc trunk give me the
assertion)
https://godbolt.org/z/6JtKsU
#include <coroutine>
struct task {
struct promise_type {
auto initial_suspend() noexcept { return std::suspend_always{}; }
auto final_suspend() noexcept { return std::suspend_always{}; }
void return_void() {}
task get_return_object() { return task{}; }
void unhandled_exception() noexcept {}
};
~task() noexcept {}
bool await_ready() const noexcept { return false; }
void await_suspend(std::coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
struct Error {
~Error() noexcept(false) {}
};
task g();
task f() {
Error error;
co_await g();
}