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

            Bug ID: 123264
           Summary: d: Infinite loop in dump_generic_node
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gcc dot gnu.org
  Target Milestone: ---

Requires address to be taken by a field, and parameter to be `const`.

```
struct Dump
{
    void infinite(const Dump) { }
    auto fn = &infinite;
}
```

Compiling with any dump flag (-fdump-tree-original=stdout) and compiler enters
infinite loop between print_struct_decl and dump_function_declaration.

bt
```
#0  dump_function_declaration (pp=pp@entry=0x3c296b0,
node=node@entry=0x7ffff77521f8, spc=spc@entry=4, flags=flags@entry=100663296)
at ../../gcc/tree-pretty-print.cc:372
#1  0x0000000001666c95 in dump_generic_node (pp=pp@entry=0x3c296b0,
node=0x7ffff77522a0, spc=spc@entry=4, flags=flags@entry=100663296,
is_stmt=is_stmt@entry=false) at ../../gcc/tree-pretty-print.cc:2418
#2  0x000000000166f591 in print_declaration (pp=pp@entry=0x3c296b0,
t=t@entry=0x7ffff773f820, spc=spc@entry=4, flags=flags@entry=100663296) at
../../gcc/tree-pretty-print.cc:4546
#3  0x000000000166fb22 in print_struct_decl (pp=pp@entry=0x3c296b0,
node=node@entry=0x7ffff7752150, spc=spc@entry=2, flags=flags@entry=100663296)
at ../../gcc/tree-pretty-print.cc:4631
#4  0x0000000001665f04 in dump_generic_node (pp=pp@entry=0x3c296b0,
node=0x7ffff7752150, spc=spc@entry=2, flags=flags@entry=100663296,
is_stmt=is_stmt@entry=false) at ../../gcc/tree-pretty-print.cc:2518
#5  0x000000000166ebd7 in dump_function_declaration (pp=pp@entry=0x3c296b0,
node=node@entry=0x7ffff77521f8, spc=spc@entry=2, flags=flags@entry=100663296)
at ../../gcc/tree.h:3752
#6  0x0000000001666c95 in dump_generic_node (pp=pp@entry=0x3c296b0,
node=0x7ffff77522a0, spc=spc@entry=2, flags=flags@entry=100663296,
is_stmt=is_stmt@entry=false) at ../../gcc/tree-pretty-print.cc:2418
#7  0x000000000166f591 in print_declaration (pp=pp@entry=0x3c296b0,
t=t@entry=0x7ffff773f820, spc=spc@entry=2, flags=flags@entry=100663296) at
../../gcc/tree-pretty-print.cc:4546
#8  0x000000000166fb22 in print_struct_decl (pp=pp@entry=0x3c296b0,
node=node@entry=0x7ffff7752150, spc=spc@entry=0, flags=flags@entry=100663296)
at ../../gcc/tree-pretty-print.cc:4631
#9  0x0000000001665f04 in dump_generic_node (pp=0x3c296b0, node=0x7ffff7752150,
spc=spc@entry=0, flags=100663296, is_stmt=is_stmt@entry=false) at
../../gcc/tree-pretty-print.cc:2518
#10 0x00000000016693b4 in print_generic_expr (file=<optimized out>,
t=<optimized out>, flags=<optimized out>) at ../../gcc/tree-pretty-print.cc:174
#11 0x00000000015af292 in dump_function_to_file
(fndecl=fndecl@entry=0x7ffff773db00, file=file@entry=0x7ffff7ac05c0
<_IO_2_1_stdout_>, flags=100663296) at ../../gcc/tree.h:3898
#12 0x0000000000fca778 in dump_function (phase=phase@entry=4,
fn=fn@entry=0x7ffff773db00) at ../../gcc/dumpfile.cc:2099
#13 0x0000000000ea80bd in finish_function (old_context=old_context@entry=0x0)
at ../../gcc/d/decl.cc:2170
#14 0x0000000000eb0ea1 in DeclVisitor::visit (this=<optimized out>,
d=0x7ffff5e97000) at ../../gcc/d/decl.cc:1105
```

Reply via email to