chriskohlhoff / asio

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

Cannot compile simple code on MSVC under /std:c++20 with /permissive #982

Open exjam opened 2 years ago

exjam commented 2 years ago

Seems to be unable to convert from io_context to any_io_executor when compiling on MSVC with /std:c++20 and /permissive.

See https://godbolt.org/z/fE5oPqb1M for example

    boost::asio::io_context ioc;
    boost::asio::ip::tcp::socket socket(ioc);
boost/asio/detail/io_object_impl.hpp(59): error C2664: 'boost::asio::any_io_executor::any_io_executor(std::nullptr_t) noexcept': cannot convert argument 1 from 'boost::asio::io_context::executor_type' to 'std::nullptr_t'
boost/asio/detail/io_object_impl.hpp(59): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

This previously did build under C++17 with both /permissive or /permissive-, see https://godbolt.org/z/f7Tc6c6Yr

Note that the default for /std:c++20 is /permissive-, but we have a large legacy codebase which will take a long time to transition to full /permissive-, so it would be great if we could get this working.

Lveyou commented 2 years ago

When I updated Visual Studio to 17.1.0 solved the problem.