https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90078
--- Comment #8 from Walter Landry <wlandry at caltech dot edu> --- (In reply to Martin Liška from comment #5) > (In reply to bin cheng from comment #4) > > Another problem is the generated binary has segment fault issue even > > compiled O0: > > > > $ ./g++ -O0 pr90078.cc -o a.out -ftemplate-depth=1000000 -ftime-report -g > > -std=c++14 > > $ gdb --args ./a.out > > > > Dump of assembler code for function main(): > > 0x0000000000400572 <+0>: push %rbp > > 0x0000000000400573 <+1>: mov %rsp,%rbp > > 0x0000000000400576 <+4>: sub $0x2625a020,%rsp > > 0x000000000040057d <+11>: lea -0x2625a020(%rbp),%rax > > 0x0000000000400584 <+18>: mov %rax,%rdi > > => 0x0000000000400587 <+21>: callq 0x4006c0 <Tensor4<float, 100, 100, > > 100, 100>::Tensor4()> > > 0x000000000040058c <+26>: lea -0x4c4b410(%rbp),%rax > > 0x0000000000400593 <+33>: lea -0xe4e1c10(%rbp),%rdx > > > > The segment fault happens at the callq instruction. > > Yes, same happens also for clang. It's a stack overflow: That is not surprising. The code recurses 1000 times. I would not consider crashing at runtime to be a bug.