Skip to content
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

clang crashes on variant construction #58028

Closed
evsergey opened this issue Sep 27, 2022 · 10 comments · Fixed by llvm/llvm-project-release-prs#175
Closed

clang crashes on variant construction #58028

evsergey opened this issue Sep 27, 2022 · 10 comments · Fixed by llvm/llvm-project-release-prs#175
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged

Comments

@evsergey
Copy link

evsergey commented Sep 27, 2022

Minimal reproduction

https://godbolt.org/z/af37KGrEd

#include <variant>

struct V1 {};

struct V2 : V1
{
    int& a;
};

int main()
{
    std::variant<V1, V2> v = V1{};
}

Stack trace

0.	Program arguments: /opt/compiler-explorer/clang-trunk-20220928/bin/clang-16 -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 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 -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20220928/lib/clang/16.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/backward -internal-isystem /opt/compiler-explorer/clang-trunk-20220928/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../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=/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-e4cc54.o -x c++ <source>
1.	<source>:12:34: current parser token ';'
2.	<source>:11:1: parsing function body 'main'
3.	<source>:11:1: in compound statement ('{}')
4.	/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/variant:1373:26: instantiating variable initializer 'std::variant<V1, V2>::__accepted_index<V1 &&>'
5.	/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/variant:781:12: instantiating class definition 'std::__detail::__variant::_Build_FUNs<V1 &&, std::variant<V1, V2>, std::integer_sequence<unsigned long, 0, 1>>'
  #0 0x0000555d09cf6184 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
  #1 0x0000555d09cf3a24 SignalHandler(int) Signals.cpp:0:0
  #2 0x00007f30d0f57420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
  #3 0x0000555d0d242246 clang::Stmt::getSourceRange() const (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6fc6246)
  #4 0x0000555d0c7dedff (anonymous namespace)::InitListChecker::FillInEmptyInitForField(unsigned int, clang::FieldDecl*, clang::InitializedEntity const&, clang::InitListExpr*, bool&, bool) SemaInit.cpp:0:0
  #5 0x0000555d0c7df4ca (anonymous namespace)::InitListChecker::FillInEmptyInitializations(clang::InitializedEntity const&, clang::InitListExpr*, bool&, clang::InitListExpr*, unsigned int, bool) SemaInit.cpp:0:0
  #6 0x0000555d0c7df458 (anonymous namespace)::InitListChecker::FillInEmptyInitializations(clang::InitializedEntity const&, clang::InitListExpr*, bool&, clang::InitListExpr*, unsigned int, bool) SemaInit.cpp:0:0
  #7 0x0000555d0c7d72e5 (anonymous namespace)::InitListChecker::InitListChecker(clang::Sema&, clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool, bool, bool) SemaInit.cpp:0:0
  #8 0x0000555d0c7d759f diagnoseListInit(clang::Sema&, clang::InitializedEntity const&, clang::InitListExpr*) SemaInit.cpp:0:0
  #9 0x0000555d0c7d85de clang::InitializationSequence::Diagnose(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::ArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x655c5de)
 #10 0x0000555d0c7da435 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x655e435)
 #11 0x0000555d0c7d57d0 (anonymous namespace)::InitListChecker::CheckSubElementType(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType, unsigned int&, clang::InitListExpr*, unsigned int&, bool) SemaInit.cpp:0:0
 #12 0x0000555d0c7e15de (anonymous namespace)::InitListChecker::CheckStructUnionTypes(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType, llvm::iterator_range<clang::CXXBaseSpecifier*>, clang::DeclContext::specific_decl_iterator<clang::FieldDecl>, bool, unsigned int&, clang::InitListExpr*, unsigned int&, bool) SemaInit.cpp:0:0
 #13 0x0000555d0c7d65ad (anonymous namespace)::InitListChecker::CheckListElementTypes(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool, unsigned int&, clang::InitListExpr*, unsigned int&, bool) (.constprop.0) SemaInit.cpp:0:0
 #14 0x0000555d0c7d6a2d (anonymous namespace)::InitListChecker::CheckExplicitInitList(clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, clang::InitListExpr*, bool) (.constprop.0) SemaInit.cpp:0:0
 #15 0x0000555d0c7d7256 (anonymous namespace)::InitListChecker::InitListChecker(clang::Sema&, clang::InitializedEntity const&, clang::InitListExpr*, clang::QualType&, bool, bool, bool) SemaInit.cpp:0:0
 #16 0x0000555d0c7d759f diagnoseListInit(clang::Sema&, clang::InitializedEntity const&, clang::InitListExpr*) SemaInit.cpp:0:0
 #17 0x0000555d0c7d85de clang::InitializationSequence::Diagnose(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::ArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x655c5de)
 #18 0x0000555d0c7da435 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x655e435)
 #19 0x0000555d0c6faa60 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x647ea60)
 #20 0x0000555d0cb921bd clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXUnresolvedConstructExpr(clang::CXXUnresolvedConstructExpr*) SemaTemplateInstantiate.cpp:0:0
 #21 0x0000555d0cb77d4b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #22 0x0000555d0cb860b1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #23 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
 #24 0x0000555d0cb8bd68 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
 #25 0x0000555d0cb90778 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName) SemaTemplateInstantiate.cpp:0:0
 #26 0x0000555d0cb86a33 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #27 0x0000555d0cb98a1d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
 #28 0x0000555d0cb85bae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #29 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
 #30 0x0000555d0cb8bd68 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
 #31 0x0000555d0cb8dc98 bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
 #32 0x0000555d0cb8ea28 clang::Sema::SubstTemplateArguments(llvm::ArrayRef<clang::TemplateArgumentLoc>, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6912a28)
 #33 0x0000555d0cb23fca _Z31FinishTemplateArgumentDeductionIN5clang38ClassTemplatePartialSpecializationDeclEENSt9enable_ifIXsr23IsPartialSpecializationIT_E5valueENS0_4Sema23TemplateDeductionResultEE4typeERS6_PS4_bRKNS0_20TemplateArgumentListERN4llvm15SmallVectorImplINS0_23DeducedTemplateArgumentEEERNS0_4sema21TemplateDeductionInfoE SemaTemplateDeduction.cpp:0:0
 #34 0x0000555d0cb24f19 void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::ClassTemplatePartialSpecializationDecl*, clang::TemplateArgumentList const&, clang::sema::TemplateDeductionInfo&)::'lambda'()>(long) SemaTemplateDeduction.cpp:0:0
 #35 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
 #36 0x0000555d0cb308fe clang::Sema::DeduceTemplateArguments(clang::ClassTemplatePartialSpecializationDecl*, clang::TemplateArgumentList const&, clang::sema::TemplateDeductionInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x68b48fe)
 #37 0x0000555d0cb73dce getPatternForClassTemplateSpecialization(clang::Sema&, clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind) (.isra.0) SemaTemplateInstantiate.cpp:0:0
 #38 0x0000555d0cbaf256 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6933256)
 #39 0x0000555d0cc2d963 void llvm::function_ref<void ()>::callback_fn<clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)::'lambda'()>(long) SemaType.cpp:0:0
 #40 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
 #41 0x0000555d0cc31e1d clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69b5e1d)
 #42 0x0000555d0cc31eb9 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69b5eb9)
 #43 0x0000555d0c53c85b clang::Sema::CheckBaseSpecifier(clang::CXXRecordDecl*, clang::SourceRange, bool, clang::AccessSpecifier, clang::TypeSourceInfo*, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x62c085b)
 #44 0x0000555d0cb92dcd clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6916dcd)
 #45 0x0000555d0cb9345c clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x691745c)
 #46 0x0000555d0cbaf2db clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69332db)
 #47 0x0000555d0cc2d963 void llvm::function_ref<void ()>::callback_fn<clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)::'lambda'()>(long) SemaType.cpp:0:0
 #48 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
 #49 0x0000555d0cc31e1d clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69b5e1d)
 #50 0x0000555d0cc31eb9 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69b5eb9)
 #51 0x0000555d0c299c59 clang::Sema::RequireCompleteDeclContext(clang::CXXScopeSpec&, clang::DeclContext*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x601dc59)
 #52 0x0000555d0c62692c clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool, clang::Scope const*, clang::TypeSourceInfo**) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x63aa92c)
 #53 0x0000555d0cb9735b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr(clang::DependentScopeDeclRefExpr*, bool, clang::TypeSourceInfo**) SemaTemplateInstantiate.cpp:0:0
 #54 0x0000555d0cb77c0b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #55 0x0000555d0cb8099d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
 #56 0x0000555d0cb77d37 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #57 0x0000555d0cb860b1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #58 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
 #59 0x0000555d0cb8aace clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x690eace)
 #60 0x0000555d0ca4c54f clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x67d054f)
 #61 0x0000555d0cb90678 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName) SemaTemplateInstantiate.cpp:0:0
 #62 0x0000555d0cb86a33 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #63 0x0000555d0cb98a1d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
 #64 0x0000555d0cb85bae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #65 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
 #66 0x0000555d0cb8bd68 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
 #67 0x0000555d0cb90778 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName) SemaTemplateInstantiate.cpp:0:0
 #68 0x0000555d0cb86a33 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #69 0x0000555d0cb98a1d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
 #70 0x0000555d0cb85bae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #71 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
 #72 0x0000555d0cb8bd68 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
 #73 0x0000555d0cb8dc98 bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
 #74 0x0000555d0cb8ea28 clang::Sema::SubstTemplateArguments(llvm::ArrayRef<clang::TemplateArgumentLoc>, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6912a28)
 #75 0x0000555d0cb2767a _Z31FinishTemplateArgumentDeductionIN5clang36VarTemplatePartialSpecializationDeclEENSt9enable_ifIXsr23IsPartialSpecializationIT_E5valueENS0_4Sema23TemplateDeductionResultEE4typeERS6_PS4_bRKNS0_20TemplateArgumentListERN4llvm15SmallVectorImplINS0_23DeducedTemplateArgumentEEERNS0_4sema21TemplateDeductionInfoE SemaTemplateDeduction.cpp:0:0
 #76 0x0000555d0cb285c9 void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::VarTemplatePartialSpecializationDecl*, clang::TemplateArgumentList const&, clang::sema::TemplateDeductionInfo&)::'lambda'()>(long) SemaTemplateDeduction.cpp:0:0
 #77 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
 #78 0x0000555d0cb30e7e clang::Sema::DeduceTemplateArguments(clang::VarTemplatePartialSpecializationDecl*, clang::TemplateArgumentList const&, clang::sema::TemplateDeductionInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x68b4e7e)
 #79 0x0000555d0ca50b12 clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::TemplateArgumentListInfo const&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x67d4b12)
 #80 0x0000555d0ca51583 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x67d5583)
 #81 0x0000555d0cb9557f clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformUnresolvedLookupExpr(clang::UnresolvedLookupExpr*) SemaTemplateInstantiate.cpp:0:0
 #82 0x0000555d0cb7781b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #83 0x0000555d0cb787f5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) SemaTemplateInstantiate.cpp:0:0
 #84 0x0000555d0cb7a1be clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x68fe1be)
 #85 0x0000555d0cbb5846 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6939846)
 #86 0x0000555d0cbf3f63 clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6977f63)
 #87 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
 #88 0x0000555d0c62450c DoMarkVarDeclReferenced(clang::Sema&, clang::SourceLocation, clang::VarDecl*, clang::Expr*, llvm::DenseMap<clang::VarDecl const*, int, llvm::DenseMapInfo<clang::VarDecl const*, void>, llvm::detail::DenseMapPair<clang::VarDecl const*, int>>&) SemaExpr.cpp:0:0
 #89 0x0000555d0c624d4c clang::Sema::MarkDeclRefReferenced(clang::DeclRefExpr*, clang::Expr const*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x63a8d4c)
 #90 0x0000555d0c625230 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x63a9230)
 #91 0x0000555d0c625ec0 clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x63a9ec0)
 #92 0x0000555d0ca515c3 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x67d55c3)
 #93 0x0000555d0cb9557f clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformUnresolvedLookupExpr(clang::UnresolvedLookupExpr*) SemaTemplateInstantiate.cpp:0:0
 #94 0x0000555d0cb7781b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #95 0x0000555d0cb77cab clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
 #96 0x0000555d0cb8bcd4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
 #97 0x0000555d0cb90778 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName) SemaTemplateInstantiate.cpp:0:0
 #98 0x0000555d0cb86a33 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #99 0x0000555d0cb98a1d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
#100 0x0000555d0cb85bae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#101 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#102 0x0000555d0cb8aace clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x690eace)
#103 0x0000555d0ca4c54f clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x67d054f)
#104 0x0000555d0cb90678 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName) SemaTemplateInstantiate.cpp:0:0
#105 0x0000555d0cb86a33 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#106 0x0000555d0cb98a1d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
#107 0x0000555d0cb85bae clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#108 0x0000555d0cb89487 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#109 0x0000555d0cb918bc clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x69158bc)
#110 0x0000555d0ca0fe46 SubstDefaultTemplateArgument(clang::Sema&, clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::TemplateTypeParmDecl*, llvm::SmallVectorImpl<clang::TemplateArgument>&) SemaTemplate.cpp:0:0
#111 0x0000555d0ca12cf5 clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::Decl*, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6796cf5)
#112 0x0000555d0cb39ac8 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 ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x68bdac8)
#113 0x0000555d0cb3b76e void llvm::function_ref<void ()>::callback_fn<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>)>)::'lambda1'()>(long) SemaTemplateDeduction.cpp:0:0
#114 0x0000555d0c253685 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5fd7685)
#115 0x0000555d0cb45063 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>)>) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x68c9063)
#116 0x0000555d0c96b1df clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x66ef1df)
#117 0x0000555d0c7c2305 TryUserDefinedConversion(clang::Sema&, clang::QualType, clang::InitializationKind const&, clang::Expr*, clang::InitializationSequence&, bool) SemaInit.cpp:0:0
#118 0x0000555d0c7d4ba7 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x6558ba7)
#119 0x0000555d0c460bc2 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x61e4bc2)
#120 0x0000555d0c12754d clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5eab54d)
#121 0x0000555d0c13ac46 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5ebec46)
#122 0x0000555d0c13bef8 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5ebfef8)
#123 0x0000555d0c13c447 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5ec0447)
#124 0x0000555d0c1e7e4e clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5f6be4e)
#125 0x0000555d0c1e86f3 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5f6c6f3)
#126 0x0000555d0c1e9616 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5f6d616)
#127 0x0000555d0c1ea262 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5f6e262)
#128 0x0000555d0c10b3b4 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5e8f3b4)
#129 0x0000555d0c13ad8f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5ebed8f)
#130 0x0000555d0c1059e5 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5e899e5)
#131 0x0000555d0c106960 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#132 0x0000555d0c10e3ed clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5e923ed)
#133 0x0000555d0c10f89a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5e9389a)
#134 0x0000555d0c0ff18a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x5e8318a)
#135 0x0000555d0af68435 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x4cec435)
#136 0x0000555d0a8702f1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x45f42f1)
#137 0x0000555d0a7f5f43 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x4579f43)
#138 0x0000555d0a95371b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x46d771b)
#139 0x0000555d07513904 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x1297904)
#140 0x0000555d0750cebb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#141 0x0000555d0750f4a0 clang_main(int, char**) (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x12934a0)
#142 0x00007f30d0a05083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#143 0x0000555d0750cace _start (/opt/compiler-explorer/clang-trunk-20220928/bin/clang-16+0x1290ace)
@shafik
Copy link
Collaborator

shafik commented Sep 27, 2022

This looks like #57370 and just like this one use -stdlib=libc++ and the problem goes away.

Although this feels a slight bit simpler.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Sep 27, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 27, 2022

@llvm/issue-subscribers-clang-frontend

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 27, 2022

@llvm/issue-subscribers-c-20

@evsergey
Copy link
Author

use -stdlib=libc++ and the problem goes away

But other problems will come like the absence of pmr and jthread

@shafik
Copy link
Collaborator

shafik commented Sep 28, 2022

use -stdlib=libc++ and the problem goes away

But other problems will come like the absence of pmr and jthread

Apologies, this is still a bug but it is important information for someone trying to reproduce the issue.

@royjacobson
Copy link
Contributor

/cherry-pick 9706bb3

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 30, 2022

/branch llvm/llvm-project-release-prs/issue58028

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Sep 30, 2022
Fixes a null dereference in some diagnostic issuing code.

Closes llvm/llvm-project#57370
Closes llvm/llvm-project#58028

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D134885

(cherry picked from commit 9706bb3)
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 30, 2022

/pull-request llvm/llvm-project-release-prs#175

@royjacobson
Copy link
Contributor

Sorry for the confusion, this isn't backported yet :)
Second attempt:

/cherry-pick 9415aad

@royjacobson royjacobson reopened this Sep 30, 2022
llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Sep 30, 2022
Fixes a null dereference in some diagnostic issuing code.

Closes llvm/llvm-project#57370
Closes llvm/llvm-project#58028

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D134885

(cherry picked from commit 9415aad)
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 30, 2022

/branch llvm/llvm-project-release-prs/issue58028

tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Oct 3, 2022
Fixes a null dereference in some diagnostic issuing code.

Closes llvm/llvm-project#57370
Closes llvm/llvm-project#58028

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D134885

(cherry picked from commit 9415aad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport release:merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants