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

            Bug ID: 123649
           Summary: [16 Regression] ICE in build_simple_base_path, at
                    cp/class.cc:608
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/YYn7dG3s4
The following c++ code crash gcc trunk.
But gcc 13,14,15 with checking is fine.
When removing the : after struct B will cause another ice.

Code:
```cpp
struct B : { // When remove : cause internal compiler error: in
             // finish_expr_stmt, at cp/semantics.cc:1171
  int j;
};
template <auto L =
              [] {
                struct D : B {};
                D d;
                d.j;
              }>
static void g();
struct A {
  virtual ~A() { g(); }
};
```

Stack dump:
```
<source>:1:12: error: expected class-name before '{' token
    1 | struct B : { // When remove : cause internal compiler error: in
      |            ^
<source>: In substitution of 'template<auto L> void g() [with auto L =
<missing>]':
required from here
<source>:13:19:   
   13 |   virtual ~A() { g(); }
      |                  ~^~
<source>:9:19: internal compiler error: in build_simple_base_path, at
cp/class.cc:608
    9 |                 d.j;
      |                 ~~^
0x2950618 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x29453db internal_error(char const*, ...)
        ???:0
0xb1eaa6 fancy_abort(char const*, int, char const*)
        ???:0
0xb76e8f build_base_path(tree_code, tree_node*, tree_node*, int, int)
        ???:0
0xe5bc05 build_class_member_access_expr(cp_expr, tree_node*, tree_node*, bool,
int)
        ???:0
0xe651f4 finish_class_member_access_expr(cp_expr, tree_node*, bool, int, bool)
        ???:0
0xd8ecbe tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xda0111 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xdca431 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xb574c9 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xe02b15 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xd647e3 c_parse_file()
        ???:0
0xeee929 c_common_parse_file()
        ???: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.
Compiler returned: 1
```

Reply via email to