chriskohlhoff / asio

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

Bug with C++20 or newer in Visual Studio #1545

Open OgreTransporter opened 1 month ago

OgreTransporter commented 1 month ago

I have loaded the current release (https://archives.boost.io/release/1.86.0/source/boost_1_86_0.7z) and created the following test project:

CMakeLists.txt

cmake_minimum_required(VERSION 3.25)
project(ASIO-Test)

set(CXX_STANDARD_REQUIRED ON)
set(Boost_USE_MULTITHREADED ON)
if(WIN32)
    set(Boost_USE_STATIC_LIBS ON)
endif()
find_package(Boost REQUIRED)

add_definitions(-D_WIN32_WINNT=0x0601)

add_executable(Test14 main.cpp)
target_include_directories(Test14 PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(Test14 PRIVATE Boost::headers)
target_compile_options(Test14 PRIVATE "/std:c++14")

add_executable(Test17 main.cpp)
target_include_directories(Test17 PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(Test17 PRIVATE Boost::headers)
target_compile_options(Test17 PRIVATE "/std:c++17")

add_executable(Test20 main.cpp)
target_include_directories(Test20 PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(Test20 PRIVATE Boost::headers)
target_compile_options(Test20 PRIVATE "/std:c++20")

add_executable(TestLatest main.cpp)
target_include_directories(TestLatest PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(TestLatest PRIVATE Boost::headers)
target_compile_options(TestLatest PRIVATE "/std:c++latest")

main.cpp

#include <boost/asio.hpp>

int main(int argc, char* argv[])
{
    return 0;
}

If the C++ standard is set to C++20 or newer, there are errors when compiling. It is sufficient to include the ASIO header. It is not necessary to use ASIO.

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>1>Checking Build System
2>------ Build started: Project: TestLatest, Configuration: Debug x64 ------
3>------ Build started: Project: Test20, Configuration: Debug x64 ------
4>------ Build started: Project: Test17, Configuration: Debug x64 ------
5>------ Build started: Project: Test14, Configuration: Debug x64 ------
2>Building Custom Rule D:/boost/CMakeLists.txt
3>Building Custom Rule D:/boost/CMakeLists.txt
2>main.cpp
4>Building Custom Rule D:/boost/CMakeLists.txt
3>main.cpp
5>Building Custom Rule D:/boost/CMakeLists.txt
4>main.cpp
5>main.cpp
2>D:\boost\boost_1_86_0\boost/asio/co_composed.hpp(162,33): error C3546: '...': there are no parameter packs available to expand
2>D:\boost\boost_1_86_0\boost/asio/co_composed.hpp(163,2): message : see reference to class template instantiation 'boost::asio::detail::co_composed_state_return<Executors,Handler,boost::asio::detail::co_composed_returns<Signatures...>>' being compiled
3>D:\boost\boost_1_86_0\boost/asio/co_composed.hpp(162,33): error C3546: '...': there are no parameter packs available to expand
3>D:\boost\boost_1_86_0\boost/asio/co_composed.hpp(163,2): message : see reference to class template instantiation 'boost::asio::detail::co_composed_state_return<Executors,Handler,boost::asio::detail::co_composed_returns<Signatures...>>' being compiled
4>Test17.vcxproj -> D:\boost\build\Debug\Test17.exe
5>Test14.vcxproj -> D:\boost\build\Debug\Test14.exe
2>Done building project "TestLatest.vcxproj" -- FAILED.
3>Done building project "Test20.vcxproj" -- FAILED.
6>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
6>Project not selected to build for this solution configuration 
========== Build: 3 succeeded, 2 failed, 0 up-to-date, 1 skipped ==========
Tofficus commented 3 weeks ago

I confirm that there is a problem in my project. Windows 10 Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.6.0 17.6.33712.159 ISO C++20 Standard (/std:c++20)

I get an error on Asio versions 1-31 and 1-32

1>init.cpp 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>main.cpp 1>TCPClient.cpp 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>TCPConnection.cpp 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>UDPFormularServer.cpp 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-31-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled

1>init.cpp 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>main.cpp 1>TCPClient.cpp 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>TCPConnection.cpp 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled 1>UDPFormularServer.cpp 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(161,33): error C3546: '...': there are no parameter packs available to expand 1>c:\dev\asio-asio-1-32-0\asio\include\asio\co_composed.hpp(162,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns>' being compiled

There is no error on version 1-28

Add:

and no problem on Microsoft Visual Studio (64-bit) Version 17.11.5 VisualStudio.17.Release/17.11.5+35327.3