chriskohlhoff / asio

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

clang-10 error: called object type 'boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *' is not a function or function pointer #1370

Open k15tfu opened 12 months ago

k15tfu commented 12 months ago

Hi!

In file boost/asio/detail/bind_handler.hpp after upgrading to Boost 1.83:

boost/asio/detail/bind_handler.hpp:60:5: error: called object type 'boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *' is not a function or function pointer
    BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)();
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boost/asio/detail/config.hpp:137:42: note: expanded from macro 'BOOST_ASIO_MOVE_OR_LVALUE'
# define BOOST_ASIO_MOVE_OR_LVALUE(type) static_cast<type&&>
                                         ^
boost/asio/handler_invoke_hook.hpp:88:3: note: in instantiation of member function 'boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>::operator()' requested here
  function();
  ^
boost/asio/detail/handler_invoke_helpers.hpp:54:3: note: in instantiation of function template specialization 'boost::asio::asio_handler_invoke<boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *> >' requested here
  asio_handler_invoke(function, boost::asio::detail::addressof(context));
  ^
boost/asio/detail/bind_handler.hpp:111:38: note: in instantiation of function template specialization 'boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>, boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>' requested here
  boost_asio_handler_invoke_helpers::invoke(
                                     ^
boost/asio/detail/handler_invoke_helpers.hpp:54:3: note: in instantiation of function template specialization 'boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>, boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>' requested here
  asio_handler_invoke(function, boost::asio::detail::addressof(context));
  ^
boost/asio/impl/system_executor.hpp:58:40: note: in instantiation of function template specialization 'boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *>, boost::asio::detail::binder0<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *> >' requested here
    boost_asio_handler_invoke_helpers::invoke(f2.value, f2.value);
                                       ^
boost/asio/system_executor.hpp:322:11: note: (skipping 4 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    this->do_execute(BOOST_ASIO_MOVE_CAST(Function)(f), Blocking());
          ^
boost/asio/dispatch.hpp:79:10: note: in instantiation of function template specialization 'boost::asio::async_initiate<boost::asio::detail::awaitable_frame_base<boost::asio::any_io_executor> *, void (), boost::asio::detail::initiate_dispatch>' requested here
  return async_initiate<NullaryToken, void()>(
         ^
boost/asio/impl/co_spawn.hpp:325:15: note: in instantiation of function template specialization 'boost::asio::detail::co_spawn_entry_point<boost::asio::detail::detached_handler, boost::asio::any_io_executor, (lambda at 1.cpp:5:37)>' requested here
    auto a = (co_spawn_entry_point)(static_cast<awaitable_type*>(nullptr),
              ^
boost/asio/impl/detached.hpp:90:5: note: in instantiation of function template specialization 'boost::asio::detail::initiate_co_spawn<boost::asio::any_io_executor>::operator()<boost::asio::detail::detached_handler, (lambda at 1.cpp:5:37)>' requested here
    BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
    ^
boost/asio/detail/config.hpp:135:37: note: expanded from macro 'BOOST_ASIO_MOVE_CAST'
# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
                                    ^
boost/asio/async_result.hpp:896:21: note: in instantiation of function template specialization 'boost::asio::async_result<boost::asio::detached_t, void (std::exception_ptr)>::initiate<boost::asio::detail::initiate_co_spawn<boost::asio::any_io_executor>, const boost::asio::detached_t &, (lambda at 1.cpp:5:37)>' requested here
    Signatures...>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
                    ^
boost/asio/impl/co_spawn.hpp:417:10: note: in instantiation of function template specialization 'boost::asio::async_initiate<const boost::asio::detached_t &, void (std::exception_ptr), boost::asio::detail::initiate_co_spawn<boost::asio::any_io_executor>, (lambda at 1.cpp:5:37)>' requested here
  return async_initiate<CompletionToken,
         ^
1 error generated.

demo app:

$ cat 1.cpp
#include <boost/asio.hpp>

void foo(boost::asio::io_service* io_serv, boost::asio::ip::tcp::acceptor* acceptor, boost::asio::ip::tcp::socket* sock)
{
    boost::asio::co_spawn(*io_serv, [=]() -> boost::asio::awaitable<void>
        {
            co_await acceptor->async_accept(*sock, boost::asio::use_awaitable);
        }, boost::asio::detached);
}