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

            Bug ID: 95481
           Summary: Failure to optimize infinite recursion for struct
                    types
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

struct A {};

struct A foo()
{
  return foo();
}

This can be optimized to an infinite loop. With -O3, GCC currently outputs an
explicit recursive call like this :

foo():
  sub rsp, 8
  call foo()
  xor eax, eax
  add rsp, 8
  ret

When it could just do this :

foo():
.L2:
  jmp .L2

Reply via email to