chriskohlhoff / asio

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

[experimental::coro] asserts for equality with noop_coroutine() are not correct #1070

Open andrei-datcu opened 2 years ago

andrei-datcu commented 2 years ago

Ex: https://github.com/chriskohlhoff/asio/blob/8869d25/asio/include/asio/experimental/impl/coro.hpp#L1014

According to cppreference:

Return values from different calls to noop_coroutine may and may not compare equal.

Would assert(!coro->awaited_from) suffice?

cc @klemens-morgenstern

klemens-morgenstern commented 2 years ago

Does the noop_coroutine equate to false?

andrei-datcu commented 2 years ago

No, it does not, sorry for the confusion.

To give more context to my original problem:

I stumbled upon this when compiling my code with -Og. Running on clang14 + libcpp14 I got the asserts erroneously triggered.

klemens-morgenstern commented 2 years ago

The assert just shouldn't be there, it's left over from development.

phprus commented 2 years ago

@klemens-morgenstern All asserts or not?

https://github.com/chriskohlhoff/asio/blob/8869d25ae2c7eb280ee6048e86b4e3d44f257323/asio/include/asio/experimental/impl/coro.hpp#L1014

https://github.com/chriskohlhoff/asio/blob/8869d25ae2c7eb280ee6048e86b4e3d44f257323/asio/include/asio/experimental/impl/coro.hpp#L1036

https://github.com/chriskohlhoff/asio/blob/8869d25ae2c7eb280ee6048e86b4e3d44f257323/asio/include/asio/experimental/impl/coro.hpp#L1086

https://github.com/chriskohlhoff/asio/blob/8869d25ae2c7eb280ee6048e86b4e3d44f257323/asio/include/asio/experimental/impl/coro.hpp#L1138

klemens-morgenstern commented 2 years ago

All of them are faulty.