https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115859
Bug ID: 115859 Summary: ICE: in lower_stmt, at gimple-low.cc:724 with -g and __attribute__((optimize(3))) Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- ******************************************************************************* OS and Platform: $ uname -a: Linux 65dac7c84719 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* gcc version: Using built-in specs. COLLECT_GCC=/home/software/gcc-trunk-3aa004f/bin/gcc COLLECT_LTO_WRAPPER=/home/software/gcc-trunk-3aa004f/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --disable-multilib --disable-bootstrap --enable-languages=c,c++ --prefix=/home/software/gcc-trunk-3aa004f --enable-coverage Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240630 (experimental) (GCC) ******************************************************************************* Program: $ cat mutant.C namespace std { template <typename a, typename> struct coroutine_traits { using promise_type = a : promise_type; } template <typename = void> struct coroutine_handle; struct coroutine_handle<> { } template <typename> struct coroutine_handle { } class b { get_return_object() } class c { using promise_type = b; }; __attribute__((optimize(3))) auto d(int awaitable) -> c { co_await awaitable ******************************************************************************* Command Lines: $ gcc -g -std=c++20 mutant.C mutant.C:3:26: error: found ':' in nested-name-specifier, expected '::' 3 | using promise_type = a : promise_type; | ^ | :: mutant.C:4:2: error: expected ';' after struct definition 4 | } template <typename = void> struct coroutine_handle; | ^ | ; mutant.C:5:1: error: an explicit specialization must be preceded by 'template <>' 5 | struct coroutine_handle<> { | ^~~~~~~~~~~~~~~~~~~~~~~~~ | template <> mutant.C:6:2: error: expected ';' after struct definition 6 | } template <typename> struct coroutine_handle { | ^ | ; mutant.C:7:2: error: expected ';' after struct definition 7 | } class b { | ^ | ; mutant.C:8:3: error: ISO C++ forbids declaration of 'get_return_object' with no type [-fpermissive] 8 | get_return_object() | ^~~~~~~~~~~~~~~~~ mutant.C:8:21: error: expected ';' at end of member declaration 8 | get_return_object() | ^ | ; mutant.C:9:2: error: expected ';' after class definition 9 | } class c { | ^ | ; mutant.C: In instantiation of 'struct std::coroutine_traits<std::c, int>': mutant.C:13:12: required from here 13 | co_await awaitable | ^~~~~~~~~ mutant.C:3:9: error: 'using std::c::promise_type = class std::b' is private within this context 3 | using promise_type = a : promise_type; | ^~~~~~~~~~~~ mutant.C:10:9: note: declared private here 10 | using promise_type = b; | ^~~~~~~~~~~~ mutant.C: In function 'std::c std::d(int)': mutant.C:13:3: error: awaitable type 'int' is not a structure 13 | co_await awaitable | ^~~~~~~~ mutant.C:13:21: error: expected '}' at end of input 13 | co_await awaitable | ^ mutant.C:12:57: note: to match this '{' 12 | __attribute__((optimize(3))) auto d(int awaitable) -> c { | ^ mutant.C:12:35: error: no member named 'initial_suspend' in 'std::coroutine_traits<std::c, int>::promise_type' {aka 'std::b'} 12 | __attribute__((optimize(3))) auto d(int awaitable) -> c { | ^ mutant.C:12:35: error: no member named 'unhandled_exception' in 'std::coroutine_traits<std::c, int>::promise_type' {aka 'std::b'} mutant.C:12:35: error: no member named 'final_suspend' in 'std::coroutine_traits<std::c, int>::promise_type' {aka 'std::b'} mutant.C:13:21: error: 'int std::b::get_return_object()' is private within this context 13 | co_await awaitable | ^ mutant.C:8:3: note: declared private here 8 | get_return_object() | ^~~~~~~~~~~~~~~~~ mutant.C:13:21: error: could not convert '_Coro_gro' from 'int' to 'std::c' 13 | co_await awaitable | ^ | | | int mutant.C: At global scope: mutant.C:13:21: error: expected '}' at end of input mutant.C:1:15: note: to match this '{' 1 | namespace std { | ^ during GIMPLE pass: lower mutant.C: In function 'void std::d(d(int)::_ZSt1di.Frame*)': mutant.C:12:35: internal compiler error: in lower_stmt, at gimple-low.cc:724 12 | __attribute__((optimize(3))) auto d(int awaitable) -> c { | ^ 0x576c1eb diagnostic_context::report_diagnostic(diagnostic_info*) ???:0 0x576cabd diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x578c98b internal_error(char const*, ...) ???:0 0x576d000 fancy_abort(char const*, int, char const*) ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Also ICE on trunk. Compiler Explorer: https://godbolt.org/z/v48f8a4fn