Issue 164312
Summary clang rejects a musttail call when it's perfectly fine to tail call
Labels clang
Assignees
Reporter ahatanak
    $ cat test.cpp
```
void foobar() noexcept;

void dance() noexcept {
#ifdef MUSTTAIL
  [[clang::musttail]]
#endif
  return foobar();
}
```

$ 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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to