https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118431
Bug ID: 118431
Summary: [Feature request]: warn about escaped local variables
in musttail instead of error-ing
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: kenjin4096 at gmail dot com
Target Milestone: ---
Dear GCC maintainers,
Currently, GCC 15.0 on commit c1729df6ec1eff4815a9cdd71392691ce21da028 blocks
functions with `musttail` from compiling if it determines a local variable
escapes:
https://github.com/gcc-mirror/gcc/blob/master/gcc/tree-tailcall.cc#L706
This leads to many false positives on real-world code when interprocedural
analysis wrongly determines something escapes, for example, a common pattern is
to pass local variables as pointers to simulate multiple return values in C.
This triggers the check above. This is one example (from a PR I am working on):
https://github.com/python/cpython/blob/d26ef11ad0259e450b53be33b87011635d4b3dce/Python/generated_tail_call_handlers.c.h#L76
May I propose to either:
1. Relax the check to a warning or if not possible,
2. Allow passing a flag to ignore that check, because a human has determined
that the value does not escape.
please?
Locally, I commented out that check in GCC and rebuilt my PR
https://github.com/python/cpython/pull/128718 (with some local patches applied)
with GCC trunk -Og, and it passes the entire CPython test suite, except for
some gdb failures which are expected.
Branched-off from previous issue at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118430
Thank you for your time.
Regards,
Ken Jin