[Bug c++/95824] New: [coroutines] compiler crash
victor.burckel at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 22 19:18:01 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95824
Bug ID: 95824
Summary: [coroutines] compiler crash
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: ---
The following code sample makes the gcc 10.1.0 compiler crash with segmentation
fault (compiled with -std=c++20 -fcoroutines). Gcc trunk generates an assertion
> internal compiler error: tree check: expected function_type or method_type, have pointer_type in captures_temporary, at cp/coroutines.cc:2690
That's the smallest piece of code I was able to reproduce on gcc 10.1.0
(removing the virtual from the makeId method or removing the virtual
inheritance from the exception fixes the issue).
On gcc trunk the exception and base classes are not necessary to generate the
assertion.
I initially got this issue when invoking a virtual method to get a feed a
parameter to a coroutine, with boost::archive::archive_exception included,
which virtually inherits from std::exception.
I managed to reproduce with godbolt
https://godbolt.org/z/tBmRxJ
#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 base
{
virtual ~base() = default;
};
class exception : public virtual base
{};
struct factory
{
virtual ~factory() = default;
virtual int makeId() const;
};
task g(int);
task f(factory& factory) {
co_await g(factory.makeId());
}
More information about the Gcc-bugs
mailing list