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

            Bug ID: 119311
           Summary: musttail attribute ineffective at -O0 and -O1
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruno at clisp dot org
  Target Milestone: ---

Created attachment 60778
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60778&action=edit
test case foo.c

The documentation https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html
says:
"If the compiler cannot generate a musttail tail call it will report an error."

But this is not what I see, with the attached program, on x86_64: At
optimization levels -O0 and -O1, non-tail calls are generated; no error is
reported.

How to reproduce:
Compile the attached foo.c with option -S.

Expected:
No "call gcd" instruction inside function 'gcd'.

Actual:
With -O0 and -O1: Two "call gcd" instructions inside function 'gcd'.

Seen with with GCC version 15.0.1 20250316 (from godbolt.org).

Reply via email to