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 via email to