public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "me at xecycle dot info" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104020] New: [coroutines] ICE in co_await function call with initializer_list arguments
Date: Fri, 14 Jan 2022 06:34:10 +0000	[thread overview]
Message-ID: <bug-104020-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 104020
           Summary: [coroutines] ICE in co_await function call with
                    initializer_list arguments
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at xecycle dot info
  Target Milestone: ---

Running example at https://godbolt.org/z/cEjTWPvYf, code with clang part
removed is:

#include <coroutine>
using std::coroutine_handle;
using std::suspend_always;
using std::suspend_never;

#include <initializer_list>
#include <string_view>

struct promise_t;

struct ret_t {
  using promise_type = promise_t;
};

struct promise_t {

  ret_t get_return_object() { return {}; }

  constexpr auto initial_suspend() noexcept { return suspend_never(); }

  void return_void() {}
  auto final_suspend() noexcept { return suspend_never(); }

  void unhandled_exception()
  {
    __builtin_trap();
  }

};

auto operator co_await(ret_t)
{
  struct W {
    auto await_ready() { return std::true_type(); }
    void await_suspend(coroutine_handle<>) {}
    void await_resume() {}
  };
  return W();
}

ret_t f1(std::initializer_list<std::string_view>)
{
  co_return;
}

ret_t f2()
{
  co_await f1({"abc", "def"});
}

ICE in 11.2, "array used as initializer" in trunk.

Can compile if either:
- the argument is std::initializer_list<int>, or
- use a separate variable, like
  std::initializer_list<std::string_view> args {"abc", "def"};
  co_await f1(args);

             reply	other threads:[~2022-01-14  6:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14  6:34 me at xecycle dot info [this message]
2022-04-17 10:43 ` [Bug c++/104020] " avi at scylladb dot com
2022-04-18 19:05 ` iains at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104020-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).