@@ -1008,6 +1008,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind)
}
/* Only build a temporary if we need it. */
+ STRIP_NOPS (e_proxy);
if (TREE_CODE (e_proxy) == PARM_DECL
|| (VAR_P (e_proxy) && !is_local_temp (e_proxy)))
{
new file mode 100644
@@ -0,0 +1,35 @@
+
+#include <coroutine>
+
+class Task {
+ public:
+ struct promise_type {
+ Task get_return_object() { return Task{}; }
+ std::suspend_always initial_suspend() { return {}; }
+ std::suspend_always final_suspend() noexcept { return {}; }
+ void unhandled_exception() {}
+ void return_void() {}
+ };
+
+ bool await_ready() const { return false; }
+ void await_suspend(std::coroutine_handle<void> continuation) {}
+ void await_resume() {}
+};
+
+class NonMoveableTask {
+ public:
+ NonMoveableTask() = default;
+ NonMoveableTask(const NonMoveableTask&) = delete;
+ NonMoveableTask(NonMoveableTask&&) = delete;
+
+ NonMoveableTask& operator=(const NonMoveableTask&) = delete;
+ NonMoveableTask& operator=(NonMoveableTask&& other) = delete;
+
+ bool await_ready() const { return false; }
+ void await_suspend(std::coroutine_handle<void>) {}
+ void await_resume() {}
+};
+
+Task Foo(NonMoveableTask* task) { co_await* task; }
+
+int main() {}
Hi, There was a missing STRIP_NOPS which meant that, in some cases, an awaiter variable could be hidden by a view-convert-expr. tested on x86_64, powerpc64le linux and x86_86 darwin. pushed to master as trivial/obvious. thanks, Iain Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/99575 gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Strip NOPs from candidate awaiter expressions before testing to see if they need a temporary. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr99575.C: New test. --- gcc/cp/coroutines.cc | 1 + gcc/testsuite/g++.dg/coroutines/pr99575.C | 35 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr99575.C