https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517
Bug ID: 95517 Summary: [coroutines] suggested warning when co_return and return_void() are missing Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bruck.michael at gmail dot com Target Milestone: --- [stmt.return.coroutine] "3 If p.return_void() is a valid expression, flowing off the end of a coroutine is equivalent to a co_return with no operand; otherwise flowing off the end of a coroutine results in undefined behavior." It would be useful to diagnose this. Example code that includes the undefined behavior and produces no warnings with -Wall -Wextra: --- #include <coroutine> struct dummy { struct promise_type { dummy get_return_object() const noexcept { return {}; } std::suspend_never initial_suspend() const noexcept { return {}; } std::suspend_never final_suspend() const noexcept { return {}; } //void return_void() const noexcept {} void unhandled_exception() const noexcept {} }; int i; // work around #95516 }; dummy foo() { co_await std::suspend_never{}; //co_return; } int main() { foo(); }