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

            Bug ID: 127324
           Summary: Infinite loop mangling a reflection of parameter
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

Found in bug 127316:

```
template<auto>
struct constant_wrapper {};

void f(int a, constant_wrapper<^^a>) {}
```

$ ./cc1plus -quiet -std=c++26 -freflection 127316-2.C
Segmentation fault         (core dumped)

#510 0x00000000006364bc in write_local_name (function=<function_decl
0x7fffe97acf00 f>, local_entity=<parm_decl 0x7fffe9610cc0 a>, 
    entity=<parm_decl 0x7fffe9610cc0 a>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:2410
#511 0x000000000062efb9 in write_name (decl=<parm_decl 0x7fffe9610cc0 a>,
ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1172
#512 0x0000000000641703 in write_reflection (refl=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4242
#513 0x000000000064315a in write_template_arg_literal (value=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4484
#514 0x00000000006438e3 in write_template_arg (node=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4570
#515 0x000000000063bb7f in write_template_args (args=<tree_vec 0x7fffe97b9440>,
parms=<tree 0x0>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3344
#516 0x000000000062ef1a in write_name (decl=<type_decl 0x7fffe97ae780
constant_wrapper>, ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1141
#517 0x000000000063afba in write_class_enum_type (type=<record_type
0x7fffe97abbd0 constant_wrapper>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3204
#518 0x000000000063749a in write_type (type=<record_type 0x7fffe97abbd0
constant_wrapper>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:2596
#519 0x000000000063aee0 in write_method_parms (parm_types=<tree_list
0x7fffe97c72a8>, method_p=0, decl=<function_decl 0x7fffe97acf00 f>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3191
#520 0x000000000063ab57 in write_bare_function_type (type=<function_type
0x7fffe97abc78>, include_return_type_p=0, 
    decl=<function_decl 0x7fffe97acf00 f>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:3127
#521 0x000000000062d923 in write_encoding (decl=<function_decl 0x7fffe97acf00
f>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:966
#522 0x00000000006364bc in write_local_name (function=<function_decl
0x7fffe97acf00 f>, local_entity=<parm_decl 0x7fffe9610cc0 a>, 
    entity=<parm_decl 0x7fffe9610cc0 a>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:2410
#523 0x000000000062efb9 in write_name (decl=<parm_decl 0x7fffe9610cc0 a>,
ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1172
#524 0x0000000000641703 in write_reflection (refl=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4242
#525 0x000000000064315a in write_template_arg_literal (value=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4484
#526 0x00000000006438e3 in write_template_arg (node=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4570
#527 0x000000000063bb7f in write_template_args (args=<tree_vec 0x7fffe97b9440>,
parms=<tree 0x0>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3344
#528 0x000000000062ef1a in write_name (decl=<type_decl 0x7fffe97ae780
constant_wrapper>, ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1141
#529 0x000000000063afba in write_class_enum_type (type=<record_type
0x7fffe97abbd0 constant_wrapper>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3204
#530 0x000000000063749a in write_type (type=<record_type 0x7fffe97abbd0
constant_wrapper>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:2596
#531 0x000000000063aee0 in write_method_parms (parm_types=<tree_list
0x7fffe97c72a8>, method_p=0, decl=<function_decl 0x7fffe97acf00 f>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3191
#532 0x000000000063ab57 in write_bare_function_type (type=<function_type
0x7fffe97abc78>, include_return_type_p=0, 
    decl=<function_decl 0x7fffe97acf00 f>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:3127
#533 0x000000000062d923 in write_encoding (decl=<function_decl 0x7fffe97acf00
f>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:966
#534 0x00000000006364bc in write_local_name (function=<function_decl
0x7fffe97acf00 f>, local_entity=<parm_decl 0x7fffe9610cc0 a>, 
    entity=<parm_decl 0x7fffe9610cc0 a>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:2410
#535 0x000000000062efb9 in write_name (decl=<parm_decl 0x7fffe9610cc0 a>,
ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1172
#536 0x0000000000641703 in write_reflection (refl=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4242
#537 0x000000000064315a in write_template_arg_literal (value=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4484
#538 0x00000000006438e3 in write_template_arg (node=<reflect_expr
0x7fffe97b9400>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:4570
#539 0x000000000063bb7f in write_template_args (args=<tree_vec 0x7fffe97b9440>,
parms=<tree 0x0>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3344
#540 0x000000000062ef1a in write_name (decl=<type_decl 0x7fffe97ae780
constant_wrapper>, ignore_local_scope=0)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:1141
#541 0x000000000063afba in write_class_enum_type (type=<record_type
0x7fffe97abbd0 constant_wrapper>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3204
#542 0x000000000063749a in write_type (type=<record_type 0x7fffe97abbd0
constant_wrapper>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:2596
#543 0x000000000063aee0 in write_method_parms (parm_types=<tree_list
0x7fffe97c72a8>, method_p=0, decl=<function_decl 0x7fffe97acf00 f>)
    at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:3191
#544 0x000000000063ab57 in write_bare_function_type (type=<function_type
0x7fffe97abc78>, include_return_type_p=0, 
    decl=<function_decl 0x7fffe97acf00 f>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:3127
#545 0x000000000062d923 in write_encoding (decl=<function_decl 0x7fffe97acf00
f>) at /home/mpolacek/src/gcc/gcc/cp/mangle.cc:966
#546 0x00000000006364bc in write_local_name (function=<function_decl
0x7fffe97acf00 f>, local_entity=<parm_decl 0x7fffe9610cc0 a>, 
    entity=<parm_decl 0x7fffe9610cc0 a>) at
/home/mpolacek/src/gcc/gcc/cp/mangle.cc:2410

Reply via email to