chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.73k stars 1.2k forks source link

Illegal indirection in spawn_handler for exception_ptr #1336

Open Tradias opened 11 months ago

Tradias commented 11 months ago

Compilation error occurs here https://github.com/chriskohlhoff/asio/blob/1f8d154829b902dbc45a651587c6c6df948358e8/asio/include/asio/impl/spawn.hpp#L692-L692 Due to missing * here https://github.com/chriskohlhoff/asio/blob/1f8d154829b902dbc45a651587c6c6df948358e8/asio/include/asio/impl/spawn.hpp#L672

Tradias commented 11 months ago

With the above change this line ha to be modified

https://github.com/chriskohlhoff/asio/blob/1f8d154829b902dbc45a651587c6c6df948358e8/asio/include/asio/impl/spawn.hpp#L691

to if (result.ex_ && *result.ex)).

Equally here:

https://github.com/chriskohlhoff/asio/blob/1f8d154829b902dbc45a651587c6c6df948358e8/asio/include/asio/impl/spawn.hpp#L583

and here:

https://github.com/chriskohlhoff/asio/blob/1f8d154829b902dbc45a651587c6c6df948358e8/asio/include/asio/impl/spawn.hpp#L811

Tradias commented 11 months ago

Here is the test code:

template <typename... T, typename CompletionToken>
auto a(CompletionToken&& token)
{
    return boost::asio::async_compose<CompletionToken, void(std::exception_ptr, T...)>(
        [](auto& op)
        {
            op.complete({}, T{}...);
        },
        token);
}

    asio::spawn(
        io_context,
        [&](auto&& yield)
        {
            a(yield);
            a<int>(yield);
            a<int, int>(yield);
        },
        [](auto eptr)
        {
            CHECK_FALSE(eptr);
        });
Tradias commented 3 months ago

While the code compiles now (Boost 1.84) the CHECK_FALSE is still triggered.