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

            Bug ID: 101765
           Summary: ICE when using a VLA inside of a coroutine
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kacper.slominski72 at gmail dot com
  Target Milestone: ---

The following code, when compiled with "-std=c++20 -fcoroutines" (on GCC
versions starting from 10.1 and including trunk) causes an ICE:
#include <coroutine>

struct dummy_coro {
        using promise_type = dummy_coro;
        bool await_ready() noexcept { return false; }
        void await_suspend(std::coroutine_handle<>) noexcept { }
        void await_resume() noexcept { }
        dummy_coro get_return_object() { return {}; }
        dummy_coro initial_suspend() { return {}; }
        dummy_coro final_suspend() noexcept { return {}; }
        void return_void() { }
        void unhandled_exception() { }
};

dummy_coro foo(int arg) {
        char arr[arg];
        co_return;
}

Compiler output from GCC 11:
<source>: In function 'dummy_coro foo(int)':
<source>:18:1: internal compiler error: Segmentation fault
   18 | }
      | ^
0x1786229 internal_error(char const*, ...)
        ???:0
0x100ff23 wi::lts_p_large(long const*, unsigned int, unsigned int, long const*,
unsigned int)
        ???:0
0x6a7c06 finish_struct_1(tree_node*)
        ???:0
0x6a9c8c finish_struct(tree_node*, tree_node*)
        ???:0
0x6cd958 morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
        ???:0
0x6fd221 finish_function(bool)
        ???:0
0x7c47db c_parse_file()
        ???:0
0x896762 c_common_parse_file()
        ???:0

Compiler output from GCC trunk:
<source>: In function 'dummy_coro foo(int)':
<source>:18:1: internal compiler error: tree check: expected integer_cst, have
plus_expr in get_len, at tree.h:6066
   18 | }
      | ^
0x1dadf09 internal_error(char const*, ...)
        ???:0
0x69f111 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x739efa finish_struct_1(tree_node*)
        ???:0
0x73ca54 finish_struct(tree_node*, tree_node*)
        ???:0
0x77d64c morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
        ???:0
0x7de6df finish_function(bool)
        ???:0
0x914885 c_parse_file()
        ???:0
0xa97472 c_common_parse_file()
        ???:0

Reply via email to