clang rejects a musttail call when it's perfectly fine to tail call
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
$ cat test.cpp
```c
void foobar() noexcept;
void dance() noexcept {
#ifdef MUSTTAIL
[[clang::musttail]]
#endif
return foobar();
}
```
```console
$ clang++ -std=c++20 -c -o /dev/null -DMUSTTAIL test.cpp
test.cpp:7:9: error: cannot compile this tail call skipping over cleanups yet
7 | return foobar();
| ^~~~~~~~
1 error generated.
```
The attempt to tail call fails because the caller (`dance`) is marked as `noexcept`, which causes `EHTerminateScope` to be pushed onto the EHStack.
I think clang should be able to do the tail call as there's no cleanup code that has to be emitted after the call in this case.
Contributor guide
Research direction
Reproduce the failure with the provided test.cpp and clang++ command, then inspect the EHStack handling of EHTerminateScope during musttail validation. Done means the noexcept musttail call compiles successfully and the regression is covered by a compiler test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100