public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98976] New: [coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr
@ 2021-02-05 13:39 mail+gnu at tzik dot jp
  2021-02-16  8:39 ` [Bug c++/98976] " iains at gcc dot gnu.org
  2021-02-16 20:45 ` [Bug c++/98976] [constexpr, coroutines] " iains at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: mail+gnu at tzik dot jp @ 2021-02-05 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98976
           Summary: [coroutines] co_return in a switch statement doesn't
                    make a generic lambda non-constexpr
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mail+gnu at tzik dot jp
  Target Milestone: ---

In a repro case below, the lambda is wrongly handled as a constexpr and its
co_return causes a compile error, as a coroutine can not be constexpr.
https://wandbox.org/permlink/y4pEMCNki1ndzJYI

The gcc here is the trunk version as of today, and the command was:
$ g++ -c -std=c++20 failcase.cc
--- failcase.cc
#include <coroutine>

struct future {
  struct promise_type {
    std::suspend_always initial_suspend() noexcept { return {};}
    std::suspend_always final_suspend() noexcept { return {}; }
    void unhandled_exception() {}
    future get_return_object() { return {}; }
    void return_void() {}
  };
};

void failcase() {
  auto foo = [](auto&&) -> future {
    switch (42) {
      case 42:
        co_return;
    }
  };
  foo(1);
}
----
The error message was:
----
prog.cc: In instantiation of 'failcase()::<lambda(auto:1&&)> [with auto:1 =
int]':
prog.cc:20:9:   required from here
prog.cc:17:9: error: 'co_return' cannot be used in a 'constexpr' function
   17 |         co_return;
      |         ^~~~~~~~~

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

* [Bug c++/98976] [coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr
  2021-02-05 13:39 [Bug c++/98976] New: [coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr mail+gnu at tzik dot jp
@ 2021-02-16  8:39 ` iains at gcc dot gnu.org
  2021-02-16 20:45 ` [Bug c++/98976] [constexpr, coroutines] " iains at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: iains at gcc dot gnu.org @ 2021-02-16  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-2-16
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=96251

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
this is most likely the same problem as PR96251

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

* [Bug c++/98976] [constexpr, coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr
  2021-02-05 13:39 [Bug c++/98976] New: [coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr mail+gnu at tzik dot jp
  2021-02-16  8:39 ` [Bug c++/98976] " iains at gcc dot gnu.org
@ 2021-02-16 20:45 ` iains at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: iains at gcc dot gnu.org @ 2021-02-16 20:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
confirmed that this is the same underlying issue as PR96251

*** This bug has been marked as a duplicate of bug 96251 ***

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

end of thread, other threads:[~2021-02-16 20:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 13:39 [Bug c++/98976] New: [coroutines] co_return in a switch statement doesn't make a generic lambda non-constexpr mail+gnu at tzik dot jp
2021-02-16  8:39 ` [Bug c++/98976] " iains at gcc dot gnu.org
2021-02-16 20:45 ` [Bug c++/98976] [constexpr, coroutines] " iains 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).