facebook / facebook/folly

Coroutine example from docs fails due to error in `experimental/coro/BlockingWait.h`: `error: non-const lvalue reference to type 'folly::coro::detail::Barrier::Awaiter' cannot bind to a temporary of type 'folly::coro::detail::Barrier::Awaiter'`

Open
#1,876 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

Using the following code, on `clang-15`, I get the below error:
```cpp
#include
#include
#include

folly::coro::Task task1() { co_return 1; }
folly::coro::Task task2() { co_return 2; }

folly::coro::Task example() {
auto [result1, result2] = co_await folly::coro::collectAll(task1(), task2());
co_return result1 + result2;
}

int main() {
auto result = folly::coro::blockingWait(example());
std::cout << result << std::endl;
}
```

```sh
vscode ➜ $ /usr/local/bin/cmake --build /build --config Debug --target all --
[0/2] Re-checking globbed directories...
[1/2] Building CXX object CMakeFiles/stupid_db.dir/src/library/db.cpp.o
FAILED: CMakeFiles/stupid_db.dir/src/library/db.cpp.o
/usr/bin/clang++-15 -DDEBUG -D_DEBUG -I/include -I/src -isystem /include -isystem /debug/lib/pkgconfig/../../../include -g -fcolor-diagnostics -Wall -Wextra -Werror -pedantic -Wthread-safety -Wthread-safety-beta -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -O0 -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address -fsanitize=undefined -fsanitize=leak -fno-sanitize-recover=all -fsanitize-address-use-after-scope -fsanitize-address-use-after-return=runtime -std=gnu++2b -MD -MT CMakeFiles/stupid_db.dir/src/library/db.cpp.o -MF CMakeFiles/stupid_db.dir/src/library/db.cpp.o.d -o CMakeFiles/stupid_db.dir/src/library/db.cpp.o -c /src/library/db.cpp

In file included from /src/library/db.cpp:6:
In file included from /include/folly/experimental/coro/BlockingWait.h:22:
In file included from /include/folly/experimental/coro/Task.h:32:
In file included from /include/folly/experimental/coro/CurrentExecutor.h:23:
In file included from /include/folly/experimental/coro/ViaIfAsync.h:24:
/include/folly/experimental/coro/Traits.h:143:10: error: non-const lvalue reference to type 'folly::coro::detail::Barrier::Awaiter' cannot bind to a temporary of type 'folly::coro::detail::Barrier::Awaiter'
return awaitable;
^~~~~~~~~
/include/folly/experimental/coro/ViaIfAsync.h:229:31: note: in instantiation of function template specialization 'folly::coro::get_awaiter' requested here
awaiter_(folly::coro::get_awaiter(
^
/include/folly/experimental/coro/ViaIfAsync.h:398:14: note: in instantiation of member function 'folly::coro::StackAwareViaIfAsyncAwaiter::StackAwareViaIfAsyncAwaiter' requested here
return StackAwareViaIfAsyncAwaiter{
^
1 error generated.
ninja: build stopped: subcommand failed.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.