Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concepts build error async_result.hpp #312

Closed
leleftheriades opened this issue Dec 24, 2019 · 10 comments
Closed

Concepts build error async_result.hpp #312

leleftheriades opened this issue Dec 24, 2019 · 10 comments

Comments

@leleftheriades
Copy link

In Visual Studio 16.3
I set the following project property:
C++ Language Standard: Preview - Features from the Latest C++ Working Draft (/std:c++latest)

Compilation fails for async_result.hpp

@215020267
Copy link

215020267 commented Jan 2, 2020

We also encountered the same problem.

Reproduce steps:

  1. git clone -c core.autocrlf=true --recursive ​https://github.com/boostorg/boost.git D:\Boost\src
  2. open a VS 2017 x64 command prompt and browse to D:\Boost\src
  3. .\bootstrap
  4. .\b2 headers variant=release --build-dir=..\out\x64rel address-model=64
  5. .\b2 variant=release --build-dir=..\out\x64rel address-model=64

ErrorMessage:
.\boost/asio/async_result.hpp(42): error C2062: type 'bool' unexpected
.\boost/asio/async_result.hpp(43): error C2143: syntax error: missing ';' before '{'
.\boost/asio/async_result.hpp(43): error C2447: '{': missing function header (old-style formal list?)
.\boost/asio/async_result.hpp(54): error C7568: argument list missing after assumed function template 'callable_with'
.\boost/asio/async_result.hpp(56): note: see reference to class template instantiation 'boost::asio::detail::is_completion_handler_for<T,R(Args...)>' being compiled
.\boost/asio/async_result.hpp(54): error C2059: syntax error: '>'
.\boost/asio/async_result.hpp(55): error C3770: 'unknown-type': is not a valid base class
.\boost/asio/async_result.hpp(61): error C2062: type 'bool' unexpected
.\boost/asio/async_result.hpp(62): error C2065: 'T': undeclared identifier
.\boost/asio/async_result.hpp(62): error C2923: 'boost::asio::detail::is_completion_signature': 'T' is not a valid template type argument for parameter 'T'
.\boost/asio/async_result.hpp(62): error C2955: 'boost::asio::detail::is_completion_signature': use of class template requires template argument list
.\boost/asio/async_result.hpp(32): note: see declaration of 'boost::asio::detail::is_completion_signature'
.\boost/asio/async_result.hpp(67): error C2061: syntax error: identifier 'completion_signature'
.\boost/asio/async_result.hpp(68): error C2062: type 'bool' unexpected
.\boost/asio/async_result.hpp(69): error C2065: 'T': undeclared identifier
.\boost/asio/async_result.hpp(69): error C2065: 'Signature': undeclared identifier
.\boost/asio/async_result.hpp(69): error C2923: 'boost::asio::detail::is_completion_handler_for': 'T' is not a valid template type argument for parameter 'T'
.\boost/asio/async_result.hpp(69): error C2923: 'boost::asio::detail::is_completion_handler_for': 'Signature' is not a valid template type argument for parameter 'Signature'
.\boost/asio/async_result.hpp(69): error C2955: 'boost::asio::detail::is_completion_handler_for': use of class template requires template argument list
.\boost/asio/async_result.hpp(48): note: see declaration of 'boost::asio::detail::is_completion_handler_for'
.\boost/asio/async_result.hpp(105): error C2039: 'completion_signature': is not a member of 'boost::asio'
.\boost/asio/async_result.hpp(25): note: see declaration of 'boost::asio'
.\boost/asio/async_result.hpp(105): error C2061: syntax error: identifier 'completion_signature'
.\boost/asio/async_result.hpp(144): error C2061: syntax error: identifier 'completion_handler_for'
.\boost/asio/async_result.hpp(190): note: see reference to class template instantiation 'boost::asio::async_result' being compiled
.\boost/asio/async_result.hpp(144): error C2988: unrecognizable template declaration/definition
.\boost/asio/async_result.hpp(144): error C2059: syntax error: ','
.\boost/asio/async_result.hpp(150): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
.\boost/asio/async_result.hpp(194): error C2039: 'completion_signature': is not a member of 'boost::asio'
.\boost/asio/async_result.hpp(25): note: see declaration of 'boost::asio'
.\boost/asio/async_result.hpp(194): error C2061: syntax error: identifier 'completion_signature'
.\boost/asio/async_result.hpp(195): error C2065: 'Signature': undeclared identifier
.\boost/asio/async_result.hpp(196): error C2977: 'boost::asio::async_result': too many template arguments
.\boost/asio/async_result.hpp(107): note: see declaration of 'boost::asio::async_result'
.\boost/asio/async_result.hpp(198): error C2913: explicit specialization; 'boost::asio::async_result' is not a specialization of a class template
.\boost/asio/async_result.hpp(205): error C2039: 'completion_signature': is not a member of 'boost::asio'
.\boost/asio/async_result.hpp(25): note: see declaration of 'boost::asio'
.\boost/asio/async_result.hpp(205): error C2061: syntax error: identifier 'completion_signature'
.\boost/asio/async_result.hpp(211): error C2065: 'Signature': undeclared identifier
.\boost/asio/async_result.hpp(251): note: see reference to class template instantiation 'boost::asio::async_completion' being compiled
.\boost/asio/async_result.hpp(250): error C2065: 'Signature': undeclared identifier
.\boost/asio/async_result.hpp(250): error C2955: 'boost::asio::async_result': use of class template requires template argument list
.\boost/asio/async_result.hpp(195): note: see declaration of 'boost::asio::async_result'
.\boost/asio/async_result.hpp(258): error C2955: 'boost::asio::async_result': use of class template requires template argument list
.\boost/asio/async_result.hpp(195): note: see declaration of 'boost::asio::async_result'
.\boost/asio/async_result.hpp(259): note: see reference to class template instantiation 'boost::asio::detail::async_result_helper<CompletionToken,Signature>' being compiled
.\boost/asio/async_result.hpp(288): error C2672: 'boost::asio::detail::async_result_initiate_memfn_helper': no matching overloaded function found
.\boost/asio/async_result.hpp(292): note: see reference to class template instantiation 'boost::asio::detail::async_result_has_initiate_memfn<CompletionToken,Signature>' being compiled
.\boost/asio/async_result.hpp(290): error C3206: 'boost::asio::detail::async_result_initiate_memfn_helper': invalid template argument for 'T', missing template argument list on class template 'boost::asio::async_result'
.\boost/asio/async_result.hpp(281): note: see declaration of 'boost::asio::detail::async_result_initiate_memfn_helper'
.\boost/asio/async_result.hpp(290): error C3206: 'boost::asio::detail::async_result_initiate_memfn_helper': invalid template argument for '', missing template argument list on class template 'boost::asio::async_result'
.\boost/asio/async_result.hpp(278): note: see declaration of 'boost::asio::detail::async_result_initiate_memfn_helper'
.\boost/asio/async_result.hpp(350): error C2039: 'completion_signature': is not a member of 'boost::asio'
.\boost/asio/async_result.hpp(25): note: see declaration of 'boost::asio'
.\boost/asio/async_result.hpp(350): error C2061: syntax error: identifier 'completion_signature'
.\boost/asio/async_result.hpp(353): error C2065: 'Signature': undeclared identifier
.\boost/asio/async_result.hpp(353): error C2923: 'boost::asio::detail::async_result_has_initiate_memfn': 'Signature' is not a valid template type argument for parameter 'Signature'
.\boost/asio/async_result.hpp(354): error C2760: syntax error: unexpected token '>', expected 'expression'
.\boost/asio/async_result.hpp(360): error C2065: 'Initiation': undeclared identifier
.\boost/asio/async_result.hpp(360): error C2065: 'initiation': undeclared identifier
.\boost/asio/async_result.hpp(361): error C2065: 'token': undeclared identifier
.\boost/asio/async_result.hpp(362): error C2065: 'Args': undeclared identifier
.\boost/asio/async_result.hpp(362): warning C4346: 'boost::asio::detail::async_result_has_initiate_memfn::value': dependent name is not a type
.\boost/asio/async_result.hpp(362): note: prefix with 'typename' to indicate a type
.\boost/asio/async_result.hpp(362): error C2988: unrecognizable template declaration/definition
.\boost/asio/async_result.hpp(362): error C2059: syntax error: '...'
.\boost/asio/async_result.hpp(363): error C2143: syntax error: missing ';' before '{'
.\boost/asio/async_result.hpp(363): error C2447: '{': missing function header (old-style formal list?)
.\boost/asio/async_result.hpp(371): error C2039: 'completion_signature': is not a member of 'boost::asio'
.\boost/asio/async_result.hpp(25): note: see declaration of 'boost::asio'
.\boost/asio/async_result.hpp(371): error C2061: syntax error: identifier 'completion_signature'

@davidstone
Copy link

Two things are causing this issue.

The first is that BOOST_ASIO_CONCEPT expands to concept bool instead of just concept. Some compilers also accept this older syntax, but it is not what's in the current draft of the standard.

The second problem is this code from async_result.hpp

template <typename T>
BOOST_ASIO_CONCEPT completion_signature =
  detail::is_completion_signature<T>::value;
template <typename T, completion_signature Signature>
BOOST_ASIO_CONCEPT completion_handler_for =
  detail::is_completion_handler_for<T, Signature>::value;

The first snippet is defining a concept. The second is trying to constrain the concept definition on the first concept, which is incorrect. Assuming the logic is otherwise correct, what you need to do here is instead (for the second snippet)

template <typename T, typename Signature>
BOOST_ASIO_CONCEPT completion_handler_for =
  completion_signature<Signature> and detail::is_completion_handler_for<T, Signature>::value;

Alternatively, is_completion_handler_for could be defined to require completion_signature for its second parameter.

@stevefan1999-personal
Copy link

Disable MSVC concepts for the time being:

if (MSVC)
  add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
endif()

@davidstone
Copy link

This does not just affect MSVC. clang trunk fails to compile the code due to the second issue I outlined, and I wouldn't be surprised if gcc trunk will fail, too.

@tchaikov
Copy link

GCC-10 also fails to build.

/opt/ceph/include/boost/asio/async_result.hpp:70:20: error: a variable concept cannot be constrained
   70 | BOOST_ASIO_CONCEPT completion_handler_for =
      |                    ^~~~~~~~~~~~~~~~~~~~~~
/opt/ceph/include/boost/asio/async_result.hpp:492:20: error: a variable concept cannot be constrained
  492 | BOOST_ASIO_CONCEPT completion_token_for = requires(T&& t)
      |                    ^~~~~~~~~~~~~~~~~~~~

the reason why it compiles with GCC-9 and before is that async_result.hpp is using the bug of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67658 , which was in turn fixed in GCC-10.

@leleftheriades leleftheriades changed the title Visual Studio 16.3 concepts build error Concepts build error Feb 12, 2020
@leleftheriades leleftheriades changed the title Concepts build error Concepts build error async_result.hpp Feb 12, 2020
@stevefan1999-personal
Copy link

Hmm, it seems like it is a complete semantic change, so not a regression, but more serious than that.

jorbo pushed a commit to WoWAddonManager/wam-client that referenced this issue Mar 7, 2020
@MakersF
Copy link

MakersF commented Mar 24, 2020

I can confirm this fails to compile with clang-11

There is a warning for the old way of specifying a concept

/boost_1_72_0/boost/asio/async_result.hpp:70:20: warning: ISO C++20 does not permit the 'bool' keyword after 'concept' [-Wconcepts-ts-compat]
BOOST_ASIO_CONCEPT completion_handler_for =
                   ^

and there is an error for constraining the concept

/boost_1_72_0/boost/asio/async_result.hpp:70:20: error: concept cannot have associated constraints

I edited the source following #312 (comment) and it worked (there is another instance of the same problem, but removing the concept from the template type and moving it anded with the requires fixes it)

@madmongo1
Copy link

Related Downstream: boostorg/beast#1884

@yumetodo
Copy link

I have just faced this issue when I specified /std:c++latest to use template syntax for generic lambdas.

LarsMichelsen pushed a commit to Checkmk/checkmk that referenced this issue Jun 10, 2020
asio hasn't tracked the latest changes in the C++ standard, see e.g.
boostorg/asio#312.

We can revert this when asio has been fixed and updated in our repo.

Change-Id: Ie6df077e851992db7d1fe5448893556d48cce594
mcvsama added a commit to mcvsama/neutrino that referenced this issue Nov 13, 2020
@ghost ghost deleted a comment from chriskohlhoff Dec 30, 2020
@ghost
Copy link

ghost commented Dec 30, 2020

This issue was moved by chriskohlhoff to chriskohlhoff/asio#738.

@ghost ghost closed this as completed Dec 30, 2020
@ghost ghost locked and limited conversation to collaborators Dec 30, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants