chriskohlhoff / asio

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

Bug: promise compile failure on MSVC #1281

Open mika-fischer opened 1 year ago

mika-fischer commented 1 year ago

Tested with:

Example code:

#include <asio/experimental/promise.hpp>
#include <asio/experimental/use_promise.hpp>
#include <asio/io_context.hpp>
#include <asio/steady_timer.hpp>

auto main() -> int {
    auto ioc = asio::io_context();
    auto timer = asio::steady_timer(ioc);
    auto promise = timer.async_wait(asio::experimental::use_promise);
    promise([&](asio::error_code) {});
    ioc.run();
}

Compile output:

C:\distlibs\host\VS\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\cl.exe  /nologo /TP -D_WIN32_WINNT=0x0601 -IC:\Users\mfischer\src\cpp\mcpp-asio\build.debug\_deps\asio-src\asio\include /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++20 /showIncludes /Fotests\CMakeFiles\foo.dir\foo.cpp.obj /Fdtests\CMakeFiles\foo.dir\ /FS -c C:\Users\mfischer\src\cpp\mcpp-asio\tests\foo.cpp
C:\Users\mfischer\src\cpp\mcpp-asio\build.debug\_deps\asio-src\asio\include\asio/experimental/impl/promise.hpp(60): error C2027: use of undefined type 'std::tuple<_Types...>'
C:\distlibs\host\VS\BuildTools\VC\Tools\MSVC\14.32.31326\include\utility(493): note: see declaration of 'std::tuple<_Types...>'
C:\Users\mfischer\src\cpp\mcpp-asio\build.debug\_deps\asio-src\asio\include\asio/experimental/impl/promise.hpp(185): note: see reference to class template instantiation 'asio::experimental::detail::promise_impl<void(Ts...),Executor,Allocator>' being compiled

Errors cleaned up:

asio/experimental/impl/promise.hpp(60): error C2027: use of undefined type 'std::tuple<_Types...>'
utility(493): note: see declaration of 'std::tuple<_Types...>'
asio/experimental/impl/promise.hpp(185): note: see reference to class template instantiation 'asio::experimental::detail::promise_impl<void(Ts...),Executor,Allocator>' being compiled

The tuple line references to this line in the MSVC STL: https://github.com/microsoft/STL/blob/b6b977885809f185189b4e3eb01a30967eba7a30/stl/inc/utility#L493

No idea how to fix it unfortunately... The include is right there in the very file that contains the error.

mika-fischer commented 1 year ago

Last working release seems to be asio-1-24-0

mika-fischer commented 1 year ago

See #1209 for a workaround