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

            Bug ID: 121734
           Summary: ICE when using VLA inside lambda with explicit object
                    parameter
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alex0w at icloud dot com
  Target Milestone: ---

This code causes ICE:

signed main() {
    int n=5;
    int mp[n];
    auto dp = [&] (this auto dp) -> int {
        return mp[0];
    };
    dp();
}

Compiler output:

<source>: In lambda function:
<source>:5:16: internal compiler error: Segmentation fault
    5 |         return mp[0];
      |                ^~
0x228dd45 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x229f296 internal_error(char const*, ...)
        ???:0
0xa06784 cp_type_quals(tree_node const*)
        ???:0
0xa068f7 build_simple_component_ref(tree_node*, tree_node*)
        ???:0
0x8b7b8e add_capture(tree_node*, tree_node*, tree_node*, bool, bool, unsigned
int*)
        ???:0
0x8b834b add_default_capture(tree_node*, tree_node*, tree_node*)
        ???:0
0x9dae64 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*,
bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned long)
        ???:0
0x98246d c_parse_file()
        ???:0
0xa8c379 c_common_parse_file()
        ???:0

godbolt link: https://godbolt.org/z/oMfndKdT4

Reply via email to