chriskohlhoff / asio

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

compile errors building client code with intel compiler 2018.2 with visual studio 2015 integration #575

Open dyollb opened 3 years ago

dyollb commented 3 years ago
  1. i built boost 1.74 with VS 2015 (release x64)

  2. when I try to build code that uses ASIO with the same MSVC version it compiles fine.

  3. when I try to build the same code with the intel c++ compiler with VS2015 integration, i get loads of compile errors.

  4. this setup has worked for us for the last 8 years (with previous versions of the compilers).

  5. following code does not compile:

    boost::asio::io_context context;
    boost::asio::ip::tcp::acceptor acceptor(context);

with following error message:

boost/asio/detail/io_object_impl.hpp(61): error : no instance of constructor "boost::asio::execution::any_executor

  1. if I define BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT the above example compiles. but following example code does not:

    boost::asio::io_context context;
    boost::asio::ip::tcp::acceptor acceptor(context);
    boost::asio::io_context::strand strand(context);
    boost::asio::ip::tcp::socket socket(context);
    
    acceptor.async_accept(socket,
        strand.wrap([](const boost::system::error_code & error) {})
    );

with the error message (I posted the complete error message below):

boost/asio/detail/handler_work.hpp(366): error : more than one partial specialization matches the template argument list of class "boost::asio::detail::handler_work_base<boost::asio::io_context::executor_type, void, boost::asio::io_context, boost::asio::executor, void>"

Questions:

1>F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/handler_work.hpp(366): error : more than one partial specialization matches the template argument list of class "boost::asio::detail::handler_work_base<boost::asio::io_context::executor_type, void, boost::asio::io_context, boost::asio::executor, void>" 1> "boost::asio::detail::handler_work_base<Executor, CandidateExecutor, IoContext, PolymorphicExecutor, boost::asio::enable_if<, void>::type>" 1> "boost::asio::detail::handler_work_base<Executor, void, IoContext, PolymorphicExecutor, boost::asio::enable_if<boost::is_same<Executor, IoContext::executor_type>::value, void>::type>" 1> handler_work_base, 1> ^ 1> detected during: 1> instantiation of class "boost::asio::detail::handler_work<Handler, IoExecutor, > [with Handler=boost::asio::detail::binder1<lambda [](const boost::system::error_code &)->void, boost::system::error_code>, IoExecutor=boost::asio::io_context::executor_type, =void]" at line 81 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/completion_handler.hpp" 1> instantiation of class "boost::asio::detail::completion_handler<Handler, IoExecutor> [with Handler=boost::asio::detail::binder1<lambda [](const boost::system::error_code &)->void, boost::system::error_code>, IoExecutor=boost::asio::io_context::executor_type]" at line 68 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/impl/strand_service.hpp" 1> instantiation of "void boost::asio::detail::strand_service::dispatch(boost::asio::detail::strand_service::implementation_type &, Handler &) [with Handler=boost::asio::detail::binder1<lambda [](const boost::system::error_code &)->void, boost::system::error_code>]" at line 344 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/io_context_strand.hpp" 1> instantiation of "void boost::asio::io_context::strand::initiate_dispatch::operator()(LegacyCompletionHandler &&, boost::asio::io_context::strand ) const [with LegacyCompletionHandler=boost::asio::detail::binder1<lambda [](const boost::system::error_code &)->void, boost::system::error_code>]" at line 183 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/async_result.hpp" 1> instantiation of "boost::asio::async_result<CompletionToken, Signature>::return_type boost::asio::async_result<CompletionToken, Signature>::initiate(Initiation &&, RawCompletionToken &&, T1 &&) [with CompletionToken=boost::asio::detail::binder1<lambda [](const boost::system::error_code &)->void, boost::system::error_code>, Signature=void (), Initiation=boost::asio::io_context::strand::initiate_dispatch, RawCompletionToken=boost::asio::detail::binder1<lambda [](const 1> boost::system::error_code &)->void, boost::system::error_code>, T1=boost::asio::io_context::strand ]" at line 470 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/async_result.hpp" 1> [ 18 instantiation contexts not shown ] 1> instantiation of "boost::asio::detail::win_iocp_socket_accept_op<Socket, Protocol, Handler, IoExecutor>::win_iocp_socket_accept_op(boost::asio::detail::win_iocp_socket_service_base &, boost::asio::detail::socket_type={SOCKET={UINT_PTR={unsigned __int64}}}, Socket &, const Protocol &, Protocol::endpoint , bool, Handler &, const IoExecutor &) [with Socket=boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, Protocol=boost::asio::ip::tcp, 1> Handler=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, lambda [](const boost::system::error_code &)->void, boost::asio::detail::is_continuation_if_running>, IoExecutor=boost::asio::any_io_executor]" at line 503 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/win_iocp_socket_service.hpp" 1> instantiation of "void boost::asio::detail::win_iocp_socket_service::async_accept(boost::asio::detail::win_iocp_socket_service::implementation_type &, Socket &, boost::asio::detail::win_iocp_socket_service::endpoint_type , Handler &, const IoExecutor &) [with Protocol=boost::asio::ip::tcp, Socket=boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, Handler=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, 1> lambda [](const boost::system::error_code &)->void, boost::asio::detail::is_continuation_if_running>, IoExecutor=boost::asio::any_io_executor]" at line 2445 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/basic_socket_acceptor.hpp" 1> instantiation of "void boost::asio::basic_socket_acceptor<Protocol, Executor>::initiate_async_accept::operator()(AcceptHandler &&, boost::asio::basic_socket<Protocol1, Executor1> , boost::asio::basic_socket_acceptor<Protocol, Executor>::endpoint_type ) const [with Protocol=boost::asio::ip::tcp, Executor=boost::asio::any_io_executor, AcceptHandler=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, lambda [](const boost::system::error_code &)->void, 1> boost::asio::detail::is_continuation_if_running>, Protocol1=boost::asio::ip::tcp, Executor1=boost::asio::any_io_executor]" at line 183 of "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/async_result.hpp" 1> instantiation of "boost::asio::async_result<CompletionToken, Signature>::return_type boost::asio::async_result<CompletionToken, Signature>::initiate(Initiation &&, RawCompletionToken &&, T1 &&, T2 &&) [with CompletionToken=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, lambda [](const boost::system::error_code &)->void, boost::asio::detail::is_continuation_if_running>, Signature=void (boost::system::error_code), 1> Initiation=boost::asio::basic_socket_acceptor<boost::asio::ip::tcp, boost::asio::any_io_executor>::initiate_async_accept, RawCompletionToken=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, lambda [](const boost::system::error_code &)->void, boost::asio::detail::is_continuation_if_running>, T1=boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> , T2=boost::asio::ip::tcp::endpoint ]" at line 470 of 1> "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/async_result.hpp" 1> instantiation of "boost::asio::enable_if<boost::asio::detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value, boost::asio::async_result<boost::decay::type, Signature>::return_type>::type boost::asio::async_initiate<CompletionToken,Signature,Initiation,T1,T2>(Initiation &&, CompletionToken &, T1 &&, T2 &&) [with CompletionToken=boost::asio::detail::wrapped_handler<boost::asio::io_context::strand, lambda [](const boost::system::error_code &)->void, 1> boost::asio::detail::is_continuation_if_running>, Signature=void (boost::system::error_code), Initiation=boost::asio::basic_socket_acceptor<boost::asio::ip::tcp, boost::asio::any_io_executor>::initiate_async_accept, T1=boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> , T2=boost::asio::ip::tcp::endpoint ]" at line 1351 of 1> "F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/basic_socket_acceptor.hpp"

dyollb commented 3 years ago

Above compile errors also occur when I use a boost built with the same compiler toolset (i.e. the intel-18.0-vc14 toolset)

kashirin-alex commented 3 years ago

It be interesting to know if using asio::strand<executor_type> let you compile.

boost::asio::io_context context;
boost::asio::ip::tcp::acceptor acceptor(context);

boost::asio::ip::tcp::socket socket(context);
boost::asio::strand<boost::asio::ip::tcp::socket::executor_type>  strand(socket.get_executor());

acceptor.async_accept(socket,
    strand.wrap([](const boost::system::error_code & error) {})
);

considering against a use case, https://github.com/kashirin-alex/swc-db/blob/beaa78966e7c7d37bb5a7f4d88e5a61c712c9fca/src/cc/include/swcdb/core/comm/ConnHandler.h#L250 while it is being used with asio::bind_executor(m_strand, hdlr)

dyollb commented 3 years ago

with BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT defined I get:

1>F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/win_iocp_overlapped_ptr.hpp(158): error : no instance of overloaded function "asio_query_fn::impl::operator()" matches the argument list 1> argument types are: (const boost::asio::io_context::executor_type, const boost::asio::execution::detail::context_t<0>) 1> object type is: const asio_queryfn::impl 1> return &boost::asio::query(ex, execution::context).impl; 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(226): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(212): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(195): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> 1>E:\Develop\Sim4Life-release\Simphony\Solvers\Networking\LazySocks\AcceptorBase.cpp(21): error : class "boost::asio::strand" has no member "wrap" 1> strand.wrap([](const boost::system::error_code & error) {})

without BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT I cannot even compile:

    boost::asio::io_context context;
    boost::asio::ip::tcp::acceptor acceptor(context);

    boost::asio::ip::tcp::socket socket(context);
    boost::asio::strand<boost::asio::ip::tcp::socket::executor_type>  strand(socket.get_executor());

1>F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/win_iocp_overlapped_ptr.hpp(158): error : no instance of overloaded function "asio_query_fn::impl::operator()" matches the argument list 1> argument types are: (const boost::asio::io_context::executor_type, const boost::asio::execution::detail::context_t<0>) 1> object type is: const asio_queryfn::impl 1> return &boost::asio::query(ex, execution::context).impl; 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(226): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(212): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/query.hpp(195): note: this candidate was rejected because at least one template argument could not be deduced 1> operator()( 1> ^ 1> 1>F:\ThirdPartyLibsRoot\svn-esx_SuperMash_libraries_boost_boost_1_74_0_z43_win_msvc-14.0-python2\include\boost/asio/detail/io_object_impl.hpp(61): error : no instance of constructor "boost::asio::execution::any_executor<T1, T2, T3, T4, T5, T6, T7, void, void>::any_executor [with T1=boost::asio::execution::context_as_t<boost::asio::execution_context &>, T2=boost::asio::execution::detail::blocking::never_t<0>, 1> T3=boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0>>, T4=boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0>>, T5=boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0>>, T6=boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0>>, 1> T7=boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0>>]" matches the argument list 1> argument types are: (boost::asio::io_context::executortype) 1> executor(context.get_executor())

kashirin-alex commented 3 years ago

seem to be everything (if I'm not wrong) is related to the strand that is used and if strand.wrap is available (asio::strand doesn't have wrap) https://github.com/chriskohlhoff/asio/issues/165 https://github.com/chriskohlhoff/asio/issues/278

I have continued with asio::bind_executor(m_strand, hdlr) https://github.com/kashirin-alex/swc-db/blob/beaa78966e7c7d37bb5a7f4d88e5a61c712c9fca/src/cc/lib/swcdb/core/comm/ConnHandler.cc#L660

dyollb commented 3 years ago

@kashirin-alex thanks. I'm not sure if these cases are related, because the same client code compiled with the same compilers with boost 1.72. the compile error appeared when we switched to boost 1.74.

chriskohlhoff commented 3 years ago

Have you tried the boost 1.75 beta? It includes some workarounds I added for the Intel compiler. They seem to work with the linux version.

Unfortunately, nobody is providing intel compiler support in boost's regression testing infrastructure, for either Windows or Linux.