Issue 91633
Summary ICE in clang::Sema::tryCaptureVariable
Labels clang
Assignees
Reporter Woebbeking
    Hi,

clang-18 crashes for me in the attached testcase [testcase.zip](https://github.com/llvm/llvm-project/files/15265917/testcase.zip)


```
0.      Program arguments: clang++ -O2 -std=c++20 -c testcase.cpp
1.      <eof> parser at end of file
2.      testcase.cpp:34:1: instantiating function definition 'findDetail<false, (lambda at testcase.cpp:62:36)>'
3.      testcase.cpp:37:23: instantiating function definition 'findDetail(const std::vector<int> &, (lambda at testcase.cpp:62:36))::(anonymous class)::operator()<Foo>'
 #0 0x00007f362f5d9a09 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.18.1+0x9d9a09)
 #1 0x00007f362f5d7430 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.18.1+0x9d7430)
 #2 0x00007f362f512ce0 (/lib64/libLLVM.so.18.1+0x912ce0)
 #3 0x00007f362e441240 __restore_rt (/lib64/libc.so.6+0x41240)
 #4 0x00007f36377fdf24 clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) (/lib64/libclang-cpp.so.18.1+0x17fdf24)
 #5 0x00007f36377bdd8b clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdd8b)
 #6 0x00007f36377bdced clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/lib64/libclang-cpp.so.18.1+0x17bdced)
 #7 0x00007f36377c2d81 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/lib64/libclang-cpp.so.18.1+0x17c2d81)
 #8 0x00007f3637cdd15f (/lib64/libclang-cpp.so.18.1+0x1cdd15f)
 #9 0x00007f3637cd2414 (/lib64/libclang-cpp.so.18.1+0x1cd2414)
#10 0x00007f3637ccf191 (/lib64/libclang-cpp.so.18.1+0x1ccf191)
#11 0x00007f3637cd3aad (/lib64/libclang-cpp.so.18.1+0x1cd3aad)
#12 0x00007f3637cd6e4d (/lib64/libclang-cpp.so.18.1+0x1cd6e4d)
#13 0x00007f3637cc8f45 (/lib64/libclang-cpp.so.18.1+0x1cc8f45)
#14 0x00007f36375c5ae9 (/lib64/libclang-cpp.so.18.1+0x15c5ae9)
#15 0x00007f36375c423b (/lib64/libclang-cpp.so.18.1+0x15c423b)
#16 0x00007f36375be82a (/lib64/libclang-cpp.so.18.1+0x15be82a)
#17 0x00007f36375be098 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/lib64/libclang-cpp.so.18.1+0x15be098)
#18 0x00007f36375c132f clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/lib64/libclang-cpp.so.18.1+0x15c132f)
#19 0x00007f3637c53859 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) (/lib64/libclang-cpp.so.18.1+0x1c53859)
#20 0x00007f3637c5543b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/lib64/libclang-cpp.so.18.1+0x1c5543b)
#21 0x00007f3637afedf7 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/lib64/libclang-cpp.so.18.1+0x1afedf7)
#22 0x00007f3637b06088 clang::Sema::AddArgumentDependentLookupCandidates(clang::DeclarationName, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::TemplateArgumentListInfo*, clang::OverloadCandidateSet&, bool) (/lib64/libclang-cpp.so.18.1+0x1b06088)
#23 0x00007f3637b154ff clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, llvm::ArrayRef<clang::Expr*>, bool) (/lib64/libclang-cpp.so.18.1+0x1b154ff)
#24 0x00007f3637b15875 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/lib64/libclang-cpp.so.18.1+0x1b15875)
#25 0x00007f36377f398d (/lib64/libclang-cpp.so.18.1+0x17f398d)
#26 0x00007f36377f3409 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/lib64/libclang-cpp.so.18.1+0x17f3409)
#27 0x00007f3637cd3c6b (/lib64/libclang-cpp.so.18.1+0x1cd3c6b)
#28 0x00007f3637cec278 (/lib64/libclang-cpp.so.18.1+0x1cec278)
#29 0x00007f3637cea103 (/lib64/libclang-cpp.so.18.1+0x1cea103)
#30 0x00007f3637cd4e51 (/lib64/libclang-cpp.so.18.1+0x1cd4e51)
#31 0x00007f3637cc1f53 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/lib64/libclang-cpp.so.18.1+0x1cc1f53)
#32 0x00007f3637d0d927 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0d927)
#33 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#34 0x00007f3637d0da63 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib64/libclang-cpp.so.18.1+0x1d0da63)
#35 0x00007f3637d10677 clang::Sema::PerformPendingInstantiations(bool) (/lib64/libclang-cpp.so.18.1+0x1d10677)
#36 0x00007f363744af37 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (/lib64/libclang-cpp.so.18.1+0x144af37)
#37 0x00007f363744b66f clang::Sema::ActOnEndOfTranslationUnit() (/lib64/libclang-cpp.so.18.1+0x144b66f)
#38 0x00007f3636b690bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/lib64/libclang-cpp.so.18.1+0xb690bd)
#39 0x00007f3636a8ec6c clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.18.1+0xa8ec6c)
#40 0x00007f3638d2a756 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.18.1+0x2d2a756)
#41 0x00007f3638c9d1b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.18.1+0x2c9d1b4)
#42 0x00007f3638da5e36 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.18.1+0x2da5e36)
#43 0x000055b776841660 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-18+0x12660)
#44 0x000055b77683e3a8 (/usr/bin/clang-18+0xf3a8)
#45 0x00007f3638916389 (/lib64/libclang-cpp.so.18.1+0x2916389)
#46 0x00007f362f512a6e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib64/libLLVM.so.18.1+0x912a6e)
#47 0x00007f36389160e0 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/lib64/libclang-cpp.so.18.1+0x29160e0)
#48 0x00007f36388ddeac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/lib64/libclang-cpp.so.18.1+0x28ddeac)
#49 0x00007f36388de0ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/lib64/libclang-cpp.so.18.1+0x28de0ee)
#50 0x00007f36388fa74c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/lib64/libclang-cpp.so.18.1+0x28fa74c)
#51 0x000055b77683dc3d clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-18+0xec3d)
#52 0x000055b77684a6e9 main (/usr/bin/clang-18+0x1b6e9)
#53 0x00007f362e42a1f0 __libc_start_call_main /usr/src/debug/glibc-2.39/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#54 0x00007f362e42a2b9 call_init /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:128:20
#55 0x00007f362e42a2b9 __libc_start_main@GLIBC_2.2.5 /usr/src/debug/glibc-2.39/csu/../csu/libc-start.c:347:5
#56 0x000055b77683ab25 _start (/usr/bin/clang-18+0xbb25)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.4
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: 
```

Maybe this is a duplicate of #90669 clang-17 works fine.

Cheers,
André
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to