Clang crashes with "undeduced type in IR-generation" on recursive template instantiation · Issue #55872 · llvm/llvm-project (original) (raw)

Clang produces a crash report with the code example that can be found here.

Stack dump: 0. Program arguments: /opt/compiler-explorer/clang-14.0.0/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-14.0.0/lib/clang/14.0.0 -internal-isystem /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/../../../../include/c++/11.2.0 -internal-isystem /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/../../../../include/c++/11.2.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/../../../../include/c++/11.2.0/backward -internal-isystem /opt/compiler-explorer/clang-14.0.0/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-11.2.0/lib/gcc/x86_64-linux-gnu/11.2.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -pedantic -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/app -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-817158.o -x c++

  1. parser at end of file
  2. :13:6: LLVM IR generation of declaration 'main'
  3. :13:6: Generating code for declaration 'main'

#0 0x0000560abff7de8f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0 #1 0x0000560abff7b74d SignalHandler(int) Signals.cpp:0:0 #2 0x00007f7bfe4343c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0) #3 0x0000560ac2824f13 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x5e24f13) #4 0x0000560ac28182ed clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x5e182ed) #5 0x0000560ac28184f5 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x5e184f5) #6 0x0000560ac043ac38 (anonymous namespace)::X86_64ABIInfo::getIndirectReturnResult(clang::QualType) const TargetInfo.cpp:0:0 #7 0x0000560ac045bbc3 (anonymous namespace)::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const TargetInfo.cpp:0:0 #8 0x0000560ac05648ca clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQualclang::Type, bool, bool, llvm::ArrayRef<clang::CanQualclang::Type >, clang::FunctionType::ExtInfo, llvm::ArrayRefclang::FunctionType::ExtParameterInfo, clang::CodeGen::RequiredArgs) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3b648ca) #9 0x0000560ac0565c1b arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes&, bool, llvm::SmallVectorImpl<clang::CanQualclang::Type >&, clang::CanQualclang::FunctionProtoType) CGCall.cpp:0:0 #10 0x0000560ac0566268 clang::CodeGen::CodeGenTypes::arrangeCXXMethodDeclaration(clang::CXXMethodDecl const*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3b66268) #11 0x0000560ac05f3d30 clang::CodeGen::CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(clang::CallExpr const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot, bool, clang::NestedNameSpecifier*, bool, clang::Expr const*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bf3d30) #12 0x0000560ac05f551e clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallExpr(clang::CXXOperatorCallExpr const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bf551e) #13 0x0000560ac05dec2a clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bdec2a) #14 0x0000560ac05f88e8 (anonymous namespace)::ComplexExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprComplex.cpp:0:0 #15 0x0000560ac05fd89d (anonymous namespace)::ComplexExprEmitter::Visit(clang::Expr*) CGExprComplex.cpp:0:0 #16 0x0000560ac05fdd90 (anonymous namespace)::ComplexExprEmitter::Visit(clang::Expr*) CGExprComplex.cpp:0:0 #17 0x0000560ac05ff504 clang::CodeGen::CodeGenFunction::EmitComplexExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bff504) #18 0x0000560ac05c52c1 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bc52c1) #19 0x0000560ac05dd416 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3bdd416) #20 0x0000560ac031061c clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x391061c) #21 0x0000560ac031627c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x391627c) #22 0x0000560ac0366433 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3966433) #23 0x0000560ac036fe7a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x396fe7a) #24 0x0000560ac03b6918 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x39b6918) #25 0x0000560ac03b3a55 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x39b3a55) #26 0x0000560ac03b4193 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x39b4193) #27 0x0000560ac03ba531 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5348) CodeGenModule.cpp:0:0 #28 0x0000560ac0f07ab1 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0 #29 0x0000560ac0efc802 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x44fc802) #30 0x0000560ac1d9a854 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x539a854) #31 0x0000560ac0f05b02 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x4505b02) #32 0x0000560ac0901161 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3f01161) #33 0x0000560ac089c2f2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3e9c2f2) #34 0x0000560ac09cc853 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x3fcc853) #35 0x0000560abdb9b1d4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x119b1d4) #36 0x0000560abdb9718d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0 #37 0x0000560abdaa6f07 main (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x10a6f07) #38 0x00007f7bfdee20b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3) #39 0x0000560abdb96d0a _start (/opt/compiler-explorer/clang-14.0.0/bin/clang-14+0x1196d0a) clang-14: error: unable to execute command: Segmentation fault (core dumped) clang-14: error: clang frontend command failed due to signal (use -v to see invocation)