public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95517] New: [coroutines] suggested warning when co_return and return_void() are missing
@ 2020-06-03 21:13 bruck.michael at gmail dot com
  2020-06-04 19:22 ` [Bug c++/95517] " iains at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bruck.michael at gmail dot com @ 2020-06-03 21:13 UTC (permalink / raw)
  To: gcc-bugs

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();
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-29 10:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 21:13 [Bug c++/95517] New: [coroutines] suggested warning when co_return and return_void() are missing bruck.michael at gmail dot com
2020-06-04 19:22 ` [Bug c++/95517] " iains at gcc dot gnu.org
2021-04-27 11:38 ` jakub at gcc dot gnu.org
2021-07-28  7:04 ` rguenth at gcc dot gnu.org
2021-08-10  3:17 ` wei_mj at 139 dot com
2021-08-10  5:32 ` iains at gcc dot gnu.org
2022-04-21  7:48 ` rguenth at gcc dot gnu.org
2023-05-29 10:02 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).