https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100901
Bug ID: 100901
Summary: "error: array used as initializer" on compiling
coroutine with initializer list with shared_ptr in it
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: greed at ispsystem dot com
Target Milestone: ---
I got same error on all compiler versions that support coroutines. To reproduce
it compile it with following params `-std=c++20 -fcoroutines`
#include <coroutine>
#include <memory>
using std::suspend_never;
auto test_ptr(std::initializer_list<std::shared_ptr<int>> values) {
return suspend_never{};
}
struct testing {
struct promise_type {
testing get_return_object() { return {}; }
void return_void() {}
suspend_never initial_suspend() noexcept { return {}; }
suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() { std::terminate(); }
};
};
testing demo() {
co_await test_ptr({std::make_shared<int>(1)});
}
int main() {
demo();
}
https://godbolt.org/z/47sjsaxMa