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

Asio from Boost 1.86.0 fails to build with C++20 w/o concepts #1547

Open
iv-m opened this issue Oct 19, 2024 · 2 comments · May be fixed by #1556
Open

Asio from Boost 1.86.0 fails to build with C++20 w/o concepts #1547

iv-m opened this issue Oct 19, 2024 · 2 comments · May be fixed by #1556

Comments

@iv-m
Copy link

iv-m commented Oct 19, 2024

When porting my software to boost 1.86.0, I found a strange error that I narrowed down to the following example.

test.cpp:

#include <boost/asio.hpp>

int main() { return 0; }
$ g++ -DBOOST_ASIO_DISABLE_CONCEPTS -std=c++20 test.cpp
In file included from /usr/include/boost/asio.hpp:69,
                 from test.cpp:2:
/usr/include/boost/asio/co_composed.hpp:849:13: error: ‘async_operation’ has not been declared
  849 |   template <async_operation Op>
      |             ^~~~~~~~~~~~~~~
/usr/include/boost/asio/co_composed.hpp:850:24: error: ‘Op’ has not been declared
  850 |   auto await_transform(Op&& op
      |                        ^~
[... and a few more errors, as compiler does not now what Op is]

I'm using x86_64 linux, gcc 13.2.1.

I see a similar error with clang 18.1.8.

If I drop -DBOOST_ASIO_DISABLE_CONCEPTS or standard specification, the code compiles just fine.

@FireBurn
Copy link

FireBurn commented Nov 4, 2024

I'm also seeing this in Clang 19.1.3

@iv-m
Copy link
Author

iv-m commented Nov 5, 2024

Yeah, same with gcc 14.2.1 and calng 19.1.3.

Also I get a similar error for the current master from this repo (bb85475):

$ cat $TMPDIR/reproducer.cpp
#include <asio.hpp>

int main() { return 0; }
$ g++ -DASIO_DISABLE_CONCEPTS -Iasio/include  -std=c++20 "$TMPDIR/reproducer.cpp"
In file included from asio/include/asio.hpp:67,
                 from /tmp/.private/iv/reproducer.cpp:1:
asio/include/asio/co_composed.hpp:848:13: error: ‘async_operation’ has not been declared
  848 |   template <async_operation Op>
      |             ^~~~~~~~~~~~~~~
asio/include/asio/co_composed.hpp:849:24: error: ‘Op’ has not been declared
  849 |   auto await_transform(Op&& op
      |                        ^~

iv-m added a commit to iv-m/asio that referenced this issue Nov 5, 2024
`async_operation` is defined only when concepts are in use.
When ASIO_DISABLE_CONCEPTS is defined, bare `typename`
should be used instead.

We can't use ASIO_ASYNC_OPERATION macros here, as it currently
does not have a no-argument form.

Fixes: chriskohlhoff#1547
@iv-m iv-m linked a pull request Nov 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants