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

            Bug ID: 115979
           Summary: Implicitly generated C++ calls stop musttail search
                    early
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi-gcc at firstfloor dot org
  Target Milestone: ---

(this bug requires committing the remaining pieces of musttail) 

When running gcc/testsuite/g++.dg/musttail11.C with -O2 we see some "cannot
tail-call: other reasons" errors.

the problem is that find_tail_calls stops at the last call before the return.
But the C++ frontend generates destructor calls, or calls for operator int
calls after the user written tail call, which stops the search early. While
these calls cannot be tail called anyways due to the extra code they should get
a proper error message, like "code after calls". But when tree-tailcalls misses
a call only expand can print not very helpful "other reasons" error.

Possible fixes: 
- When a function has f->has_musttail set but no call is found search again,
but don't stop at the first call.
- Or maybe if f->has_musttail is set just keep searching
- Or add some way for the frontend to indicate a call is generated implicitly
and can be skipped.

Reply via email to