Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[[musttail]] does not work in trivial noexcept functions #53087

Open
chfast opened this issue Jan 8, 2022 · 1 comment
Open

[[musttail]] does not work in trivial noexcept functions #53087

chfast opened this issue Jan 8, 2022 · 1 comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@chfast
Copy link
Contributor

chfast commented Jan 8, 2022

There is no way to use [[clang::musttail]] in any noexcept function.

int call(int) noexcept;

int musttail(int x) noexcept
{
    [[clang::musttail]] return call(x);
}

https://godbolt.org/z/s9vYzPbqr

<source>:5:32: error: cannot compile this tail call skipping over cleanups yet
    [[clang::musttail]] return call(x);
                               ^~~~~~~

It would be nice if clang could handle this basic case where the callee is also noexcept and the exception cleanup section is not actually needed.

@chfast chfast added clang:frontend Language frontend issues, e.g. anything involving "Sema" new issue labels Jan 8, 2022
@haberman
Copy link
Contributor

That error comes from here:

CGM.ErrorUnsupported(MustTailCall, "tail call skipping over cleanups");

It seems that there must be something on the cleanup stack that either isn't an EHCleanupScope or for which isRedundantBeforeReturn() returns false.

Unfortunately I don't know an easy way to dump the cleanup stack in Godbolt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

3 participants