https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105804
Bug ID: 105804
Summary: List-initialized argument in await expression is
doubly freed
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
#include <coroutine>
#include <memory>
struct my_params {
std::unique_ptr<int> ptr; // or any other object with nontrivial dtor
};
static std::suspend_never take_params(my_params params)
{
return {};
}
struct coro_t {
struct promise_type {
coro_t get_return_object() { return {}; }
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() noexcept {}
};
};
static coro_t my_coro()
{
co_await take_params({ std::make_unique<int>(5) });
}
int main()
{
my_coro();
}
Expected output: Same as /bin/true
Actual: free(): double free detected in tcache 2
https://godbolt.org/z/8f9d3TzYo
Probably same root cause as bug 98056 and/or bug 103871, but since the symptoms
are way different (it's a wrong-code, not just rejects-valid), I think it
warrants a separate report.