| Issue |
174987
|
| Summary |
[Clang] Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"` failed.
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Xniao
|
***Generated by fuzzer.***
Clang assertions trunk crashed but trunk is fine.
Goes back to 6.0.1.
Compiler Explorer: https://godbolt.org/z/16vKGc5cb
## Program
```cpp
#include <iostream>
template <int &T> void FuncTemplate() {
std::cout << T << std::endl;
}
enum { E = 0, F = 1 };
template <int N, int M = ((N == 1) ? F : E)> class S {};
template <int N> struct T {
static void foo(S<N> *p) {
S<N> u;
[&u]() -> bool {
static int InternalVar;
FuncTemplate<InternalVar>();
}();
}
};
int main() { T<0>().foo(0); }
```
## Stack Dump
```bash
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From*) [with To = llvm::DICompositeType; From = llvm::DIScope]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:12:5: Generating code for declaration 'T::foo(S<N> *)::(lambda)::operator()'
#0 0x00000000042ffb48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42ffb48)
#1 0x00000000042fcf74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42fcf74)
#2 0x000000000423fd48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000079b9da642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079b9da6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000079b9da642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000079b9da6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000079b9da62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000079b9da639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000004627700 clang::CodeGen::CGDebugInfo::getFunctionDeclaration(clang::Decl const*) (.part.0) CGDebugInfo.cpp:0:0
#10 0x000000000462896b clang::CodeGen::CGDebugInfo::emitFunctionStart(clang::GlobalDecl, clang::SourceLocation, clang::SourceLocation, clang::QualType, llvm::Function*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x462896b)
#11 0x000000000488705b clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x488705b)
#12 0x000000000488c63c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x488c63c)
#13 0x00000000048fa4d0 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48fa4d0)
#14 0x00000000048f5144 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48f5144)
#15 0x00000000049027fc clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49027fc)
#16 0x0000000004902718 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4902718)
#17 0x0000000004902718 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4902718)
#18 0x0000000004902718 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4902718)
#19 0x0000000004906493 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4906493)
#20 0x0000000004c675ee (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#21 0x0000000004c65005 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c65005)
#22 0x0000000006a350bc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a350bc)
#23 0x0000000004c657e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c657e8)
#24 0x0000000004f5db65 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f5db65)
#25 0x0000000004eddc6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eddc6e)
#26 0x000000000505829d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x505829d)
#27 0x0000000000de87de cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde87de)
#28 0x0000000000ddf1aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#29 0x0000000000ddf32d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#30 0x0000000004cd84e9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x00000000042401e4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42401e4)
#32 0x0000000004cd8aff clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x0000000004c99492 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c99492)
#34 0x0000000004c9a43e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c9a43e)
#35 0x0000000004ca1895 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ca1895)
#36 0x0000000000de4b51 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde4b51)
#37 0x0000000000c8e8a4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc8e8a4)
#38 0x000079b9da629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x000079b9da629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000ddec45 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xddec45)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs