chriskohlhoff / asio

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

Error in using asio::deferred for completion handlers that return std::exception_ptr #1190

Closed ashtum closed 8 months ago

ashtum commented 1 year ago

There is a bug in dereferencing exceptions_ptr in awaitable_async_op_handler<R(std::exception_ptr, Ts...), Executor> and awaitable_async_op_handler<R(std::exception_ptr, T), Executor>

It tries to dereference strcut result_type instead of exceptions_ptr;

https://github.com/chriskohlhoff/asio/blob/a71f5232d207b4f3bbd253eb1041e30b5e4ea606/asio/include/asio/impl/awaitable.hpp#L955 https://github.com/chriskohlhoff/asio/blob/a71f5232d207b4f3bbd253eb1041e30b5e4ea606/asio/include/asio/impl/awaitable.hpp#L1070

boost_1_81_0/boost/asio/impl/awaitable.hpp:956:9: fatal error: indirection requires pointer operand ('boost::asio::detail::awaitable_async_op_handler<void (std::__exception_ptr::exception_ptr, unsigned int), boost::asio::any_io_executor>::result_type' invalid)
    if (*result)
        ^~~~~~~