Created attachment 51326 [details] preprocessed file showing the issue gcc-11 can't compile the bellow code: $ cat test.cxx #include <coroutine> using namespace std; struct awaitable { awaitable() = default; awaitable(const awaitable&) = delete; awaitable(const awaitable&&) = delete; bool await_ready() { return false; } void await_suspend(coroutine_handle<> h) { } void await_resume() {} }; awaitable& request(); struct task{ struct promise_type { task get_return_object() { return {}; } suspend_never initial_suspend() { return {}; } suspend_never final_suspend() noexcept { return {}; } void return_void() {} void unhandled_exception() {} }; }; task test_coroutine() { co_await request(); } $ g++-11 -v Using built-in specs. COLLECT_GCC=g++-11 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.1.0-1ubuntu1~21.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-RPS7jb/gcc-11-11.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-RPS7jb/gcc-11-11.1.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~21.04) The error message is: $ g++-11 -std=c++20 -c test.cxx test.cxx: In function ‘task test_coroutine()’: test.cxx:28:22: error: use of deleted function ‘awaitable::awaitable(const awaitable&&)’ 28 | co_await request(); | ^ test.cxx:8:5: note: declared here 8 | awaitable(const awaitable&&) = delete; | ^~~~~~~~~ The reason is that the co_await expression is trying to create a new object and use the result of request() to move-construct it. This behavior is not compliant with the standard. In chapter 7.6.2.3 note 3.4 is saying that: e is an lvalue referring to the result of evaluating the (possibly-converted) o. So when the above function call returned an lvalue reference the e should be a reference to the o not a new object.
Fixed in r12-9435-g6fd32842404ac1. *** This bug has been marked as a duplicate of bug 105406 ***