Skip to content

[clang] crash when using [[clang::musttail]] on function marked [[noreturn]] #76631

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

Closed
philnik777 opened this issue Dec 30, 2023 · 2 comments · Fixed by #77727
Closed

[clang] crash when using [[clang::musttail]] on function marked [[noreturn]] #76631

philnik777 opened this issue Dec 30, 2023 · 2 comments · Fixed by #77727
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@philnik777
Copy link
Contributor

[[noreturn]] void throw_int() {
  throw int();
}

void throw_int_wrapper() {
  [[clang::musttail]] return throw_int();
}

causes clang to crash: https://godbolt.org/z/vvPh9KGGn

@philnik777 philnik777 added the clang:codegen IR generation bugs: mangling, exceptions, etc. label Dec 30, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 30, 2023

@llvm/issue-subscribers-clang-codegen

Author: Nikolas Klauser (philnik777)

```c++ [[noreturn]] void throw_int() { throw int(); }

void throw_int_wrapper() {
[[clang::musttail]] return throw_int();
}

causes clang to crash: https://godbolt.org/z/vvPh9KGGn
</details>

@philnik777 philnik777 added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Dec 30, 2023
jcsxky added a commit that referenced this issue Jan 17, 2024
Call function with no-return attribute generates code with unreachable
instruction instead of return and if the call statement has
`clang::musttail` attribute, it would crash in `VerifyPass`. Check this
condition in Sema ahead.
Fix [issue](#76631)

Co-authored-by: huqizhi <[email protected]>
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang:codegen IR generation bugs: mangling, exceptions, etc. labels Jan 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2024

@llvm/issue-subscribers-clang-frontend

Author: Nikolas Klauser (philnik777)

```c++ [[noreturn]] void throw_int() { throw int(); }

void throw_int_wrapper() {
[[clang::musttail]] return throw_int();
}

causes clang to crash: https://godbolt.org/z/vvPh9KGGn
</details>

ampandey-1995 pushed a commit to ampandey-1995/llvm-project that referenced this issue Jan 19, 2024
…7727)

Call function with no-return attribute generates code with unreachable
instruction instead of return and if the call statement has
`clang::musttail` attribute, it would crash in `VerifyPass`. Check this
condition in Sema ahead.
Fix [issue](llvm#76631)

Co-authored-by: huqizhi <[email protected]>
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" crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants