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

            Bug ID: 127911
           Summary: ICE in set_contract_capture_flag, at cp/semantics.cc
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s.kimura.h41104 at gmail dot com
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/1ohWfK36d

Reproducer:
```
typedef __INTPTR_TYPE__ intptr_t;

template <typename T> void foo(T n) {
  intptr_t buf[n];
  [&buf]() { __typeof(buf) baz; }();
}

void bar() { foo(42); }
```

Backtrace:
<source>: In instantiation of 'void foo(T) [with T = int]':
<source>:8:17:   required from here
    8 | void bar() { foo(42); }
      |              ~~~^~~~
<source>:5:23: internal compiler error: in set_contract_capture_flag, at
cp/semantics.cc:4704
    5 |   [&buf]() { __typeof(buf) baz; }();
      |                      ~^~~~
0x2c5c398 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2c50fdb internal_error(char const*, ...)
        ???:0
0xb9d16a fancy_abort(char const*, int, char const*)
        ???:0
0xe9caa7 process_outer_var_ref(tree_node*, int, bool)
        ???:0
0xe30b6a tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xe31722 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xe2173f tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xe5cb4d instantiate_decl(tree_node*, bool, bool)
        ???:0
0xe66b2a instantiate_pending_templates(int)
        ???:0
0xcc7158 c_parse_final_cleanups()
        ???:0
0xf8b8c8 c_common_parse_file()
        ???:0


This ICE goes back to gcc-16:
https://godbolt.org/z/W9ohWMn4q

Reply via email to