public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96784] New: Templated lambda body remains constexpr despite having co_await in body
@ 2020-08-25 16:11 kacper.slominski72 at gmail dot com
  2021-08-28 22:05 ` [Bug c++/96784] " pinskia at gcc dot gnu.org
  2021-08-28 22:08 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: kacper.slominski72 at gmail dot com @ 2020-08-25 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96784
           Summary: Templated lambda body remains constexpr despite having
                    co_await in body
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kacper.slominski72 at gmail dot com
  Target Milestone: ---

When a templated lambda has a fold expression with co_await inside of it in
it's body, it remains constexpr which causes a compile error. When compiling
the following code (with "-std=c++20 -fcoroutines -Wall -Wextra -c"):
#include <coroutine>
#include <utility>
#include <cstddef>

struct dummy_coro {
        using promise_type = dummy_coro;
        bool await_ready() { return false; }
        void await_suspend(std::coroutine_handle<>) { }
        void await_resume() { }
        dummy_coro get_return_object() { return {}; }
        dummy_coro initial_suspend() { return {}; }
        dummy_coro final_suspend() { return {}; }
        void return_void() { }
        void unhandled_exception() { }
};

dummy_coro foo() {
        co_await []<size_t ...I>(std::index_sequence<I...>) -> dummy_coro {
                ((co_await [](int){ return std::suspend_never{}; }(I)), ...);
        }(std::make_index_sequence<1>{});
}

The following error is produced:
test.cpp: In instantiation of
‘_Z3foov.actor(foo()::_Z3foov.frame*)::<lambda(std::index_sequence<I ...>)>
[with long unsigned int ...I = {0}; std::index_sequence<I ...> =
std::integer_sequence<long unsigned int, 0>]’:
test.cpp:20:33:   required from here
test.cpp:19:5: error: ‘co_await’ cannot be used in a ‘constexpr’ function
   19 |   ((co_await [](int){ return std::suspend_never{}; }(I)), ...);
      |    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The error goes away when the body also contains a co_return/co_await/co_yield
that is not in a fold expression.

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

* [Bug c++/96784] Templated lambda body remains constexpr despite having co_await in body
  2020-08-25 16:11 [Bug c++/96784] New: Templated lambda body remains constexpr despite having co_await in body kacper.slominski72 at gmail dot com
@ 2021-08-28 22:05 ` pinskia at gcc dot gnu.org
  2021-08-28 22:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there are some missing noexcept(true) in the testcases which I had to add
to allow it compile in a more recent GCC version.

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

* [Bug c++/96784] Templated lambda body remains constexpr despite having co_await in body
  2020-08-25 16:11 [Bug c++/96784] New: Templated lambda body remains constexpr despite having co_await in body kacper.slominski72 at gmail dot com
  2021-08-28 22:05 ` [Bug c++/96784] " pinskia at gcc dot gnu.org
@ 2021-08-28 22:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 96251.

*** 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-08-28 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 16:11 [Bug c++/96784] New: Templated lambda body remains constexpr despite having co_await in body kacper.slominski72 at gmail dot com
2021-08-28 22:05 ` [Bug c++/96784] " pinskia at gcc dot gnu.org
2021-08-28 22:08 ` pinskia 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).