https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112341
Bug ID: 112341
Summary: error: insufficient contextual information to
determine type on co_await result in function template
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ed at catmur dot uk
Target Milestone: ---
#include <coroutine>
struct A { int j; };
struct B {
bool await_ready();
bool await_suspend(std::coroutine_handle<>);
A await_resume();
};
struct C {
struct promise_type {
std::suspend_always initial_suspend();
std::suspend_always final_suspend() noexcept;
void unhandled_exception();
C get_return_object();
void return_void();
};
};
C f(auto) { (co_await B()).j; }
void g() { f(0); }
<source>: In function 'C f(auto:1)':
<source>:17:14: error: insufficient contextual information to determine type
17 | C f(auto) { (co_await B()).j; }
| ~^~~~~~~~~~~~~
Writing 'auto&& a = co_await B(); a.j;' or even 'auto(co_await B()).j' accepts.