https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107288

--- Comment #2 from Richard Hodges <hodges.r at gmail dot com> ---
Some extra diagnostic. Reducing to this minimal program:

```
#include <boost/asio/awaitable.hpp>
#include <boost/asio/co_spawn.hpp>
#include <boost/asio/detached.hpp>
#include <boost/asio/io_context.hpp>

namespace asio = boost::asio;

struct foo
{
    std::string s;
    int         i;
};

struct bar : foo
{
    bar(std::string s, int i)
    : foo { .s = std::move(s), .i = i }
    {
    }
};

asio::awaitable< void >
co_foo(foo)
{
    std::printf("%s\n", __func__);
    co_return;
};

asio::awaitable< void >
co_bar(foo)
{
    std::printf("%s\n", __func__);
    co_return;
};

asio::awaitable< void >
co_test()
{
    // this works
    co_await co_bar(bar("Hello, World!", 1));
    // this works but this crashes
    co_await co_foo({ .s = "Hello, World!", .i = 1 });
}

int
main()
{
    asio::io_context ioc;
    asio::co_spawn(ioc, co_test(), asio::detached);
    ioc.run();
}
```

Output:
```
co_bar
co_foo
Segmentation fault (core dumped)
```

So it seems related to the interplay between designated initialisers and
coroutines.

Reply via email to