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

            Bug ID: 125170
           Summary: [15 Regression] ICE in gimple_add_tmp_var on co_await
                    of pointer-to-member-function call
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: piersh at hotmail dot com
  Target Milestone: ---

Created attachment 64355
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64355&action=edit
pre-processed repro

A coroutine member function that does `co_await` on a call made through a
pointer-to-member-function — `co_await (this->*pmf)()` — ICEs in
gimple_add_tmp_var on GCC 15.1.1. GCC 14 accepts the same code (regression).
A direct call (`co_await this->bar()`) is accepted; the ICE only fires when
the awaited call is dispatched through a pmf.

Reduced test case (19 lines, only <coroutine> required):

    #include <coroutine>

    struct Future {
        struct promise_type {
            Future get_return_object() { return {}; }
            std::suspend_never initial_suspend() noexcept { return {}; }
            std::suspend_never final_suspend() noexcept { return {}; }
            void return_void() {}
            void unhandled_exception() {}
        };
        bool await_ready() { return true; }
        void await_suspend(std::coroutine_handle<>) {}
        void await_resume() {}
    };

    struct Foo {
        Future test(Future (Foo::*fn)()) {
            co_await (this->*fn)();
            co_return;
        }
    };

Command:
    g++ -std=c++20 -c bug.cpp

Output:
    bug.cpp: In function 'void Foo::test(...Frame*)':
    bug.cpp:18:29: internal compiler error: in gimple_add_tmp_var, at
gimplify.cc:834
       18 |         co_await (this->*fn)();
          |                  ~~~~~~~~~~~^~

Status by version:
    GCC 14   : accepts (clean compile)  -- reporter verified
    GCC 15.1 : ICE
    trunk    : not tested by reporter

Compiler details:
    gcc version 15.1.1 20250521 (Red Hat 15.1.1-2) (GCC)
    Target: x86_64-redhat-linux
    Configured with: --enable-bootstrap --enable-languages=c,c++,fortran,lto
        --enable-checking=release --with-arch_64=x86-64-v3
        --enable-host-pie --enable-host-bind-now
        (full configure line available; trimmed for brevity)

Host: Rocky Linux 10.1, x86_64, kernel 6.6.87.2 (WSL2).

Notes / shape of the trigger:
 - `pmf` may be a function parameter, a local variable, or captured by
   value or reference into a coroutine lambda — all forms ICE identically.
 - `-fcoroutines` is not needed (implied by `-std=c++20`); `-std=gnu++20`
   reproduces equivalently.
 - No optimization flags or sanitizers are required.
 - `-Wall -Wextra` clean before the ICE; no diagnostics other than the ICE.

Preprocessed source attached.

Reply via email to