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

            Bug ID: 119423
           Summary: ICE in expand_expr_real_1
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: geoff.ramseyer at cs dot stanford.edu
  Target Milestone: ---

Created attachment 60850
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60850&action=edit
Output of building with -fbug-report

Internal compile found when building the following snippet on gcc 14.2.0 (the
homebrew distribution) on macos 15.3.2

The error seems to disappear if the definition of Reader::read() is moved from
event.cc into event.h (full bugreport attached).


// async.h
#pragma once

#include <coroutine>
#include <source_location>

template<typename R> class AwaitableImpl {
public:
  using resume_type = R;

  AwaitableImpl(AwaitableImpl &&) = delete;

  std::suspend_never initial_suspend() const noexcept { return {}; }
  void unhandled_exception() {}

  struct TailCoro {
    bool await_ready() const noexcept { return false; }
    std::coroutine_handle<> await_suspend(std::coroutine_handle<>) const
noexcept;
    void await_resume() const noexcept;
  };
  TailCoro final_suspend() noexcept;

  bool await_ready() noexcept;
  void await_suspend(std::coroutine_handle<> h, std::source_location loc =
std::source_location::current()) noexcept
  {}

  R await_resume();


protected:
  AwaitableImpl() noexcept = default;
  ~AwaitableImpl();

private:

  R result_;
};

template<typename R> struct [[nodiscard]] Async {
  struct promise_type : AwaitableImpl<R> {
    promise_type(const auto &...args)
    {}
    Async get_return_object();
    void return_value(auto&& r) {}
  };

  [[nodiscard]] Async(Async &&other) noexcept
  {}

  promise_type operator co_await();

};

// event.h

#pragma once

#include <source_location>
#include <x23/async.h>

class Reader {
public:

  Async<int> f();
  Async<int> read(std::source_location sloc = std::source_location::current());
};

// event.cc

#include "x23/async.h"
#include <source_location>
#include "x23/event.h"

Async<int>
Reader::read(std::source_location sloc)
{
  co_return co_await f();
}


Build configuration:

Apple M3 system with MacOS Sequoia 15.3.2

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/aarch64-apple-darwin24/14/lto-wrapper
Target: aarch64-apple-darwin24
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc
--libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls
--enable-checking=release --with-gcc-major-version-only
--enable-languages=c,c++,objc,obj-c++,fortran,m2 --program-suffix=-14
--with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr
--with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl
--with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 14.2.0_1'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--with-system-zlib --build=aarch64-apple-darwin24
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Homebrew GCC 14.2.0_1)

// Target: aarch64-apple-darwin24
// Configured with: ../configure --prefix=/opt/homebrew/opt/gcc
--libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls
--enable-checking=release --with-gcc-major-version-only
--enable-languages=c,c++,objc,obj-c++,fortran,m2 --program-suffix=-14
--with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr
--with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl
--with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 14.2.0_1'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--with-system-zlib --build=aarch64-apple-darwin24
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
// Thread model: posix
// Supported LTO compression algorithms: zlib zstd
// gcc version 14.2.0 (Homebrew GCC 14.2.0_1) 
// 
// /Users/geoff/groundhog/hogd/x23/x23/event.cc: In member function 'Async<int>
Reader::read(std::source_location)':
// /Users/geoff/groundhog/hogd/x23/x23/event.cc:7:35: warning: unused parameter
'sloc' [-Wunused-parameter]
//     7 | Reader::read(std::source_location sloc)
//       |              ~~~~~~~~~~~~~~~~~~~~~^~~~
// In file included from /Users/geoff/groundhog/hogd/x23/x23/event.cc:2:
// /Users/geoff/groundhog/hogd/x23/x23/async.h: In instantiation of 'void
AwaitableImpl<R>::await_suspend(std::__n4861::coroutine_handle<void>,
std::source_location) [with R = int]':
// /Users/geoff/groundhog/hogd/x23/x23/event.cc:9:24:   required from here
//     9 |   co_return co_await f();
//       |                        ^
// /Users/geoff/groundhog/hogd/x23/x23/async.h:25:46: warning: unused parameter
'h' [-Wunused-parameter]
//    25 |   void await_suspend(std::coroutine_handle<> h, std::source_location
loc = std::source_location::current()) noexcept
//       |                      ~~~~~~~~~~~~~~~~~~~~~~~~^
// /Users/geoff/groundhog/hogd/x23/x23/async.h:25:70: warning: unused parameter
'loc' [-Wunused-parameter]
//    25 |   void await_suspend(std::coroutine_handle<> h, std::source_location
loc = std::source_location::current()) noexcept
//       |                                                
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// /Users/geoff/groundhog/hogd/x23/x23/async.h: In instantiation of 'void
Async<R>::promise_type::return_value(auto:2&&) [with auto:2 = int; R = int]':
// /Users/geoff/groundhog/hogd/x23/x23/event.cc:9:24:   required from here
//     9 |   co_return co_await f();
//       |                        ^
// /Users/geoff/groundhog/hogd/x23/x23/async.h:45:30: warning: unused parameter
'r' [-Wunused-parameter]
//    45 |     void return_value(auto&& r) {}
//       |                       ~~~~~~~^
// /Users/geoff/groundhog/hogd/x23/x23/async.h: In instantiation of
'Async<R>::promise_type::promise_type(const auto:1& ...) [with auto:1 =
{Reader, std::source_location}; R = int]':
// /Users/geoff/groundhog/hogd/x23/x23/event.cc:10:1:   required from here
//    10 | }
//       | ^
// /Users/geoff/groundhog/hogd/x23/x23/async.h:42:30: warning: unused parameter
'args#0' [-Wunused-parameter]
//    42 |     promise_type(const auto &...args)
//       |                  ~~~~~~~~~~~~^~~~~~~
// /Users/geoff/groundhog/hogd/x23/x23/async.h:42:30: warning: unused parameter
'args#1' [-Wunused-parameter]
// during RTL pass: expand
// /Users/geoff/groundhog/hogd/x23/x23/event.cc:10:1: internal compiler error:
in expand_expr_real_1, at expr.cc:11376
//    10 | }
//       | ^
// Please submit a full bug report, with preprocessed source.
// See <https://github.com/Homebrew/homebrew-core/issues> for instructions.

//
/opt/homebrew/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/aarch64-apple-darwin24/14/cc1plus
-quiet -I /Users/geoff/groundhog/hogd/gcc_build/built_headers -I
/Users/geoff/groundhog/hogd/external/wasm3/source -I
/Users/geoff/groundhog/hogd/gcc_build/libsodium_build-prefix/src/libsodium_build-build/src/libsodium/include
-I /Users/geoff/groundhog/hogd/external/libsodium/src/libsodium/include -I
/Users/geoff/groundhog/hogd/external/libsodium/src/libsodium/include/sodium -I
/Users/geoff/groundhog/hogd/x23 -I /Users/geoff/groundhog/hogd/gcc_build/x23
-iprefix
/opt/homebrew/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/
-MD CMakeFiles/x23.dir/event.cc.d -MF CMakeFiles/x23.dir/event.cc.o.d -MT
x23/x23/CMakeFiles/x23.dir/event.cc.o -D__DYNAMIC__ -D DEBUG
/Users/geoff/groundhog/hogd/x23/x23/event.cc -fPIC -quiet -dumpdir
CMakeFiles/x23.dir/ -dumpbase event.cc.cc -dumpbase-ext .cc
-mmacosx-version-min=15.0.0 -mlittle-endian -mabi=lp64 -mcpu=apple-m3 -g -O0
-Wextra -Wall -Wno-interference-size -std=c++23 -freport-bug -o -
-frandom-seed=0 -fdump-noaddr

Reply via email to