llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.59k stars 11.82k forks source link

ICE in `clang::Sema::CheckTemplateArgument(clang::TypeSourceInfo*)` #62578

Open ericniebler opened 1 year ago

ericniebler commented 1 year ago

Attached is auto-generated repro script and source. Compile with -std=c++20.

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: /usr/lib/llvm-16/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -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 -debugger-tuning=gdb -fcoverage-compilation-dir=/home/eniebler/Code -resource-dir /usr/lib/llvm-16/lib/clang/16 -I stdexec/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/eniebler/Code -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/test-19804e.o -x c++ test.cpp
1.      test.cpp:22:42: current parser token '=='
2.      test.cpp:20:12: parsing function body 'main'
3.      test.cpp:20:12: in compound statement ('{}')
4.      stdexec/include/stdexec/__detail/__tuple.hpp:27:28: instantiating variable definition 'stdexec::tuple_size_v<stdexec::__tuple<(lambda at stdexec/include/stdexec/__detail/__tuple.hpp:190:18)>>'
5.      stdexec/include/stdexec/__detail/__meta.hpp:403:10: instantiating class definition 'stdexec::__mexpand<stdexec::__tuple<(lambda at stdexec/include/stdexec/__detail/__tuple.hpp:190:18)>>'
  #0 0x00007ff9b71bb546 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfbb546)
  #1 0x00007ff9b71b96e0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb96e0)
  #2 0x00007ff9b71bbd1b (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfbbd1b)
  #3 0x00007ff9b5a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
  #4 0x00007ff9bf12798e clang::Sema::CheckTemplateArgument(clang::TypeSourceInfo*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x192798e)
  #5 0x00007ff9bf13b5c5 clang::Sema::CheckTemplateTypeArgument(clang::TemplateTypeParmDecl*, clang::TemplateArgumentLoc&, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x193b5c5)
  #6 0x00007ff9bf132ce6 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1932ce6)
  #7 0x00007ff9bf131cb9 clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1931cb9)
  #8 0x00007ff9bf248d18 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a48d18)
  #9 0x00007ff9bf256275 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a56275)
 #10 0x00007ff9bf2541df (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a541df)
 #11 0x00007ff9bf233243 clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, clang::CXXRecordDecl*, clang::Qualifiers, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a33243)
 #12 0x00007ff9bf271149 clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*, llvm::SmallVectorImpl<clang::ParmVarDecl*>&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a71149)
 #13 0x00007ff9bf26df92 clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*, clang::TemplateParameterList*, std::optional<clang::ASTTemplateArgumentListInfo const*>, clang::TemplateDeclInstantiator::RewriteKind) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a6df92)
 #14 0x00007ff9bf2a0484 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1aa0484)
 #15 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
 #16 0x00007ff9bf277133 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a77133)
 #17 0x00007ff9bf1d8d88 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 ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19d8d88)
 #18 0x00007ff9bf22c407 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a2c407)
 #19 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
 #20 0x00007ff9bf1da401 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19da401)
 #21 0x00007ff9bf0b7280 clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7280)
 #22 0x00007ff9bf0b7c53 clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7c53)
 #23 0x00007ff9bf0ceaf7 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18ceaf7)
 #24 0x00007ff9bede7871 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15e7871)
 #25 0x00007ff9bedff9ad clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ff9ad)
 #26 0x00007ff9bf2400b1 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a400b1)
 #27 0x00007ff9bf24e111 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a4e111)
 #28 0x00007ff9bf245839 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a45839)
 #29 0x00007ff9bf239952 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a39952)
 #30 0x00007ff9bec66a07 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1466a07)
 #31 0x00007ff9bec658f9 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14658f9)
 #32 0x00007ff9bec60b5f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1460b5f)
 #33 0x00007ff9bec6050c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x146050c)
 #34 0x00007ff9bf13a194 clang::Sema::CheckConceptTemplateId(clang::CXXScopeSpec const&, clang::SourceLocation, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::ConceptDecl*, clang::TemplateArgumentListInfo const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x193a194)
 #35 0x00007ff9bf240b9b (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a40b9b)
 #36 0x00007ff9bf239952 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a39952)
 #37 0x00007ff9bec66a07 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1466a07)
 #38 0x00007ff9bec658f9 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14658f9)
 #39 0x00007ff9bec60b5f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1460b5f)
 #40 0x00007ff9bec6050c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x146050c)
 #41 0x00007ff9bec62e05 clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1462e05)
 #42 0x00007ff9bf1d8f5f 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 ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19d8f5f)
 #43 0x00007ff9bf22c407 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a2c407)
 #44 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
 #45 0x00007ff9bf1da401 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19da401)
 #46 0x00007ff9bf0b7280 clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7280)
 #47 0x00007ff9bf0b7c53 clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7c53)
 #48 0x00007ff9bf0ceaf7 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18ceaf7)
 #49 0x00007ff9bede7871 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15e7871)
 #50 0x00007ff9bedff9ad clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ff9ad)
 #51 0x00007ff9bf2400b1 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a400b1)
 #52 0x00007ff9bf24e111 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a4e111)
 #53 0x00007ff9bf245839 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a45839)
 #54 0x00007ff9bf239952 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a39952)
 #55 0x00007ff9bec66a07 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1466a07)
 #56 0x00007ff9bec658f9 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14658f9)
 #57 0x00007ff9bec60b5f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1460b5f)
 #58 0x00007ff9bec6050c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x146050c)
 #59 0x00007ff9bf13a194 clang::Sema::CheckConceptTemplateId(clang::CXXScopeSpec const&, clang::SourceLocation, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::ConceptDecl*, clang::TemplateArgumentListInfo const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x193a194)
 #60 0x00007ff9bf240b9b (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a40b9b)
 #61 0x00007ff9bf239952 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a39952)
 #62 0x00007ff9bec66a07 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1466a07)
 #63 0x00007ff9bec658f9 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x14658f9)
 #64 0x00007ff9bec60b5f (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1460b5f)
 #65 0x00007ff9bec6050c clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x146050c)
 #66 0x00007ff9bec62e05 clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1462e05)
 #67 0x00007ff9bf1d8f5f 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 ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19d8f5f)
 #68 0x00007ff9bf22c407 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a2c407)
 #69 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
 #70 0x00007ff9bf1da401 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x19da401)
 #71 0x00007ff9bf0b7280 clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7280)
 #72 0x00007ff9bf0b7c53 clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18b7c53)
 #73 0x00007ff9bf0ceaf7 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x18ceaf7)
 #74 0x00007ff9bede7871 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15e7871)
 #75 0x00007ff9bedff9ad clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ff9ad)
 #76 0x00007ff9bf2400b1 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a400b1)
 #77 0x00007ff9bf252797 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a52797)
 #78 0x00007ff9bf232160 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32160)
 #79 0x00007ff9bf232af7 clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32af7)
 #80 0x00007ff9bf131e4a clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1931e4a)
 #81 0x00007ff9bf248d18 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a48d18)
 #82 0x00007ff9bf256275 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a56275)
 #83 0x00007ff9bf2541df (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a541df)
 #84 0x00007ff9bf232160 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32160)
 #85 0x00007ff9bf231e1c clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a31e1c)
 #86 0x00007ff9bf2682cb clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(clang::TypedefNameDecl*, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a682cb)
 #87 0x00007ff9bf26948d clang::TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(clang::TypeAliasTemplateDecl*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a6948d)
 #88 0x00007ff9bf235ee6 clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a35ee6)
 #89 0x00007ff9bf237d75 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a37d75)
 #90 0x00007ff9bf2e0bde (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1ae0bde)
 #91 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
 #92 0x00007ff9bf2d31aa clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1ad31aa)
 #93 0x00007ff9bf2d2980 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1ad2980)
 #94 0x00007ff9beba5a18 clang::Sema::RequireCompleteDeclContext(clang::CXXScopeSpec&, clang::DeclContext*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x13a5a18)
 #95 0x00007ff9bf124ea2 clang::Sema::LookupTemplateName(clang::LookupResult&, clang::Scope*, clang::CXXScopeSpec&, clang::QualType, bool, bool&, clang::Sema::RequiredTemplateKind, clang::Sema::AssumedTemplateKind*, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1924ea2)
 #96 0x00007ff9bf124b51 clang::Sema::isTemplateName(clang::Scope*, clang::CXXScopeSpec&, bool, clang::UnqualifiedId const&, clang::OpaquePtr<clang::QualType>, bool, clang::OpaquePtr<clang::TemplateName>&, bool&, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1924b51)
 #97 0x00007ff9bf13ac7b clang::Sema::ActOnTemplateName(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId const&, clang::OpaquePtr<clang::QualType>, bool, clang::OpaquePtr<clang::TemplateName>&, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x193ac7b)
 #98 0x00007ff9bf23b191 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a3b191)
 #99 0x00007ff9bf249a26 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a49a26)
#100 0x00007ff9bf248700 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a48700)
#101 0x00007ff9bf256275 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a56275)
#102 0x00007ff9bf2541df (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a541df)
#103 0x00007ff9bf232160 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32160)
#104 0x00007ff9bf232af7 clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32af7)
#105 0x00007ff9bf131e4a clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1931e4a)
#106 0x00007ff9bf248d18 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a48d18)
#107 0x00007ff9bf256275 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a56275)
#108 0x00007ff9bf2541df (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a541df)
#109 0x00007ff9bf232160 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32160)
#110 0x00007ff9bf232af7 clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32af7)
#111 0x00007ff9bf131e4a clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1931e4a)
#112 0x00007ff9bf248d18 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a48d18)
#113 0x00007ff9bf256275 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a56275)
#114 0x00007ff9bf2541df (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a541df)
#115 0x00007ff9bf232160 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a32160)
#116 0x00007ff9bf2498aa (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a498aa)
#117 0x00007ff9bf2391c8 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a391c8)
#118 0x00007ff9bf244e01 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a44e01)
#119 0x00007ff9bf23719f clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a3719f)
#120 0x00007ff9bf275b26 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a75b26)
#121 0x00007ff9bf279eec clang::Sema::CompleteVarTemplateSpecializationDecl(clang::VarTemplateSpecializationDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a79eec)
#122 0x00007ff9bf27a97f clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1a7a97f)
#123 0x00007ff9beb2e15d clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x132e15d)
#124 0x00007ff9bee23efd (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1623efd)
#125 0x00007ff9bedec2d8 clang::Sema::MarkDeclRefReferenced(clang::DeclRefExpr*, clang::Expr const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ec2d8)
#126 0x00007ff9bedebcb1 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ebcb1)
#127 0x00007ff9bedebb90 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15ebb90)
#128 0x00007ff9bedefb4b clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15efb4b)
#129 0x00007ff9bf13a549 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x193a549)
#130 0x00007ff9bede6ec9 clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool, clang::CorrectionCandidateCallback*, bool, clang::Token*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x15e6ec9)
#131 0x00007ff9be42293d clang::Parser::tryParseCXXIdExpression(clang::CXXScopeSpec&, bool, clang::Token&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc2293d)
#132 0x00007ff9be423ada clang::Parser::ParseCXXIdExpression(bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc23ada)
#133 0x00007ff9be416ddc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc16ddc)
#134 0x00007ff9be4173c3 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc173c3)
#135 0x00007ff9be4123ff clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc123ff)
#136 0x00007ff9be414045 clang::Parser::ParseConstantExpressionInExprEvalContext(clang::Parser::TypeCastState) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc14045)
#137 0x00007ff9be3fe579 clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbfe579)
#138 0x00007ff9be3df26c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbdf26c)
#139 0x00007ff9be46f8b6 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc6f8b6)
#140 0x00007ff9be46dd4d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc6dd4d)
#141 0x00007ff9be4761e0 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc761e0)
#142 0x00007ff9be47729f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc7729f)
#143 0x00007ff9be491400 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc91400)
#144 0x00007ff9be3e1322 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbe1322)
#145 0x00007ff9be490537 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc90537)
#146 0x00007ff9be48ff59 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc8ff59)
#147 0x00007ff9be48f1f7 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc8f1f7)
#148 0x00007ff9be48d59e clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xc8d59e)
#149 0x00007ff9be3cd24e clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbcd24e)
#150 0x00007ff9bffe5525 clang::FrontendAction::Execute() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x27e5525)
#151 0x00007ff9bff62714 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x2762714)
#152 0x00007ff9c005dfa4 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x285dfa4)
#153 0x000055ef07fb5d9c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-16/bin/clang+0x14d9c)
#154 0x000055ef07fb3040 (/usr/lib/llvm-16/bin/clang+0x12040)
#155 0x000055ef07fb2c79 clang_main(int, char**) (/usr/lib/llvm-16/bin/clang+0x11c79)
#156 0x00007ff9b5a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#157 0x00007ff9b5a29e40 call_init ./csu/../csu/libc-start.c:128:20
#158 0x00007ff9b5a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#159 0x000055ef07faf6a5 _start (/usr/lib/llvm-16/bin/clang+0xe6a5)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 16.0.3 (++20230427123333+bd6783b38076-1~exp1~20230427123443.81)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-560a57.cpp
clang: note: diagnostic msg: /tmp/test-560a57.sh
clang: note: diagnostic msg: 

********************

test-560a57.zip

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend

cor3ntin commented 1 year ago

It seems related to constraint checking @erichkeane

chfast commented 1 year ago

Reduced: https://godbolt.org/z/3cb4K6Wbn

shafik commented 1 year ago

code

template <typename>
bool is_same_v;
template <typename, typename _Up>
concept __same_as = is_same_v<_Up>;
template <class _Fun>
concept __callable = requires(_Fun __fun) { __fun(); };
template <class>
int __v;
using __msuccess = int;
template <int>
struct __i {
    template <template <class> class _Fn, class... _Args>
    using __g = _Fn<_Args...>;
};
template <class _Arg>
concept __ok = __same_as<_Arg, __msuccess>;
template <class... _Args>
concept _Ok = (__ok<_Args> && ...);
template <template <class> class _Fn, class... _Args>
using __meval = __i<_Ok>::__g<_Fn, _Args...>;
template <class _Fn>
using __minvoke = __meval<_Fn::template __f>;
template <class>
struct __mexpand;
template <class, class _List>
using __mapply = __minvoke<__mexpand<_List>>;
struct __msize;
template <class _Fun>
using __call_result_t = decltype(_Fun()());
template <class... _As>
concept constructible_from = __is_constructible(_As...);
template <class>
concept move_constructible = constructible_from<>;
template <class>
struct __tuple;
struct {
    template <class _Fun, class _Fun2>
        requires __callable<_Fun2>
    auto operator()(_Fun, _Fun2);
} __tuple_apply_fn;
template <class _Fun, class _Continuation>
using __tuple_types_fn =
    decltype(__tuple_apply_fn(_Fun(), []<class...>() -> _Continuation {}));
struct __gen_tuple_fun_fn {
    auto operator()() {
        return [] {};
    }
};
template <move_constructible...>
using __gen_tuple_fun_t = __gen_tuple_fun_fn;
template <class...>
using __tuple_t = __tuple<__call_result_t<__gen_tuple_fun_t<>>>;
struct __make_tuple_fn {
    __tuple_t<> operator()();
};
template <class _Fun>
struct __mexpand<__tuple<_Fun>> {
    template <class _MetaFn>
    using __f = __tuple_types_fn<_Fun, _MetaFn>;
};
template <class _Tuple>
constexpr long tuple_size_v = __v<__mapply<__msize, _Tuple>>;
template <class...>
using tuple = __call_result_t<__make_tuple_fn>;
using T = tuple<>;
static_assert(tuple_size_v<T>);
shafik commented 1 year ago

Seems like there are multiple ways to get similar crashes, possible related to: https://github.com/llvm/llvm-project/issues/60778

erichkeane commented 1 year ago

@shafik: That reproducer doesn't seem to compile in GCC either, which makes fixing based off that reproducer really difficult. Any chance you can re-run the minimization with a constraint that its still a valid program?

chfast commented 1 year ago

@shafik: That reproducer doesn't seem to compile in GCC either, which makes fixing based off that reproducer really difficult. Any chance you can re-run the minimization with a constraint that its still a valid program?

Unfortunately, I was not able to compiler the original code in any compiler version (including GCC). The only option I did was to add -Werror -ferror-count=1 to crashing clang to limit the number of syntax errors introduced to the reducing tool.

@ericniebler do you maybe have a variant of this that compiles in any other compiler?

ericniebler commented 1 year ago

I never said the code was valid. It still shouldn't ICE the compiler.

erichkeane commented 1 year ago

I never said the code was valid. It still shouldn't ICE the compiler.

I definitely don't disagree there, we obviously never want to ICE. But 'crash on invalid' is a mix of 'lower priority' and 'harder to debug', so I was hoping that it was valid, but was minimized or preprocessed in a way that caused it to be illegal.