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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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 ` iains at gcc dot gnu.org
  2021-04-27 11:38 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-04 19:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0
   Last reconfirmed|                            |2020-06-04
           Severity|normal                      |enhancement
           Assignee|unassigned at gcc dot gnu.org      |iains at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
Generally, it's not required to diagnose UB, however I think we can do better
with the co_return/return stuff and have some ideas in mind already. So, yes
this a good idea,

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-27 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.0                        |11.2

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.1 has been released, retargeting bugs to GCC 11.2.

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: wei_mj at 139 dot com @ 2021-08-10  3:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

mengjun wei <wei_mj at 139 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wei_mj at 139 dot com

--- Comment #4 from mengjun wei <wei_mj at 139 dot com> ---
GCC 11.2 no longer allow return_value and return_void be both defined, may this
restriction be removed? This makes the co_return statement necessary:
CTask workflow_work(CTaskScheduler::RawPtr scheduler,
co_comm_ctx::co_comm_workflow* workflow, const char* buf, int len)
{
        co_comm_resp_impl::ptr response(new co_comm_resp_impl);
        co_await co_comm_ctx::short_req_task::create(workflow, 1, buf, len,
response);
        co_await co_comm_ctx::short_req_task::create(workflow, 2, buf, len,
response);
        co_await co_comm_ctx::resp_task::create(workflow,
response->result.c_str(), response->result.length());
        co_return 0;
}

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: iains at gcc dot gnu.org @ 2021-08-10  5:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

--- Comment #5 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to mengjun wei from comment #4)
> GCC 11.2 no longer allow return_value and return_void be both defined, may
> this restriction be removed? 

The restriction is part of the C++ standard (for the record, there was
discussion about allowing both to be present, but that was rejected by the
committee).

https://eel.is/c++draft/dcl.fct.def.coroutine#6

So, we cannot remove the restriction.

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug c++/95517] [coroutines] suggested warning when co_return and return_void() are missing
  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
                   ` (5 preceding siblings ...)
  2022-04-21  7:48 ` rguenth at gcc dot gnu.org
@ 2023-05-29 10:02 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95517

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

^ 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).