asio icon indicating copy to clipboard operation
asio copied to clipboard

Bug with C++20 or newer in Visual Studio

Open OgreTransporter opened this issue 1 year ago • 4 comments

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 ==========
  • Operating system: Windows 10
  • Visual Studio: Microsoft Visual Studio 2022 (17.11.5)
  • Compiler: MSVC 19.36.32546 (x64)

OgreTransporter avatar Oct 17 '24 09:10 OgreTransporter

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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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<Signatures...>>' 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

Tofficus avatar Oct 28 '24 07:10 Tofficus

I'm facing the same issue with c++20 + VS2022 17.12.3 + VC 14.36. Any news ?

etiennearnal avatar Dec 06 '24 15:12 etiennearnal

The problem still exists, environment: boost1.89 & msvc17.6. Although this is a bug in the compiler, I hope someone can provide a modified version of asio\co_composed.hpp to circumvent this bug.

asio\co_composed.hpp(162,33): error C3546: '...': there are no parameter packs available to expand asio\co_composed.hpp(163,2): message : see reference to class template instantiation 'asio::detail::co_composed_state_return<Executors,Handler,asio::detail::co_composed_returns<Signatures...>>' being compiled

liuaifu avatar Sep 11 '25 12:09 liuaifu

I encountered this issue but then it was resolved by updating Visual Studio. My original environment is: Win11 x64, VS 17.x, asio 1.32. After updating the Visual Studio to v17.14.19, this compilation problem was fixed.

tomwillow avatar Nov 07 '25 05:11 tomwillow