Closed
Description
Update: See #110401 (comment) for a reduced version + cc1 invocations.
Given a.ccm
:
module;
#include <variant>
#include <string>
export module A;
export using Foo = std::variant<int, std::string, std::monostate>;
struct S {
Foo x = std::monostate{};
};
and b.ccm
:
module;
#include <variant>
export module B;
import A;
void f() {
Foo x;
auto y = x;
}
Attempting to compile this asserts on trunk (https://godbolt.org/z/sqWax9eKq). I have not been able to reproduce this w/o modules (yet, but I’ll keep trying). #102353 seems to be the same assertion, but I’m not sure they’re related.
/root/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4439:
llvm::PointerUnion<clang::Decl*, llvm::SmallVector<clang::VarDecl*, 4>*>*
clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl*):
Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' failed.
Invocation:
/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -isystem/opt/compiler-explorer/libs/fmt/7.1.3/include -O2 -g -DNDEBUG -std=gnu++26 -MD -MT CMakeFiles/bug.dir/b.ccm.o -MF CMakeFiles/bug.dir/b.ccm.o.d @CMakeFiles/bug.dir/b.ccm.o.modmap -o CMakeFiles/bug.dir/b.ccm.o -c /app/b.ccm
It’s clearly crashing in b.ccm
, but that might be due to a faulty module being emitted for a.ccm
. I’m unfortunately not that familiar w/ our modules implementation, so I don’t know which one is more likely.
Stack trace:
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-module-interface -disable-free -clear-ast-before-backend -main-file-name b.ccm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/app/build -fcoverage-compilation-dir=/app/build -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240928/lib/clang/20 -dependency-file CMakeFiles/bug.dir/b.ccm.o.d -MT CMakeFiles/bug.dir/b.ccm.o -sys-header-deps -module-file-deps -isystem /opt/compiler-explorer/libs/fmt/7.1.3/include -D NDEBUG -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240928/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.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 -O2 -std=gnu++26 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=A=CMakeFiles/bug.dir/A.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/bug.dir/B.pcm -x c++ /app/b.ccm
1. /app/b.ccm:8:15: current parser token ';'
2. /app/b.ccm:6:10: parsing function body 'f'
3. /app/b.ccm:6:10: in compound statement ('{}')
4. /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/variant:582:7: instantiating function definition 'std::__detail::__variant::_Copy_ctor_base<false, int, std::basic_string<char>, std::monostate>::_Copy_ctor_base'
5. /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/variant:185:5: instantiating function definition 'std::__detail::__variant::__raw_idx_visit<(lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/variant:586:4), const std::variant<int, std::basic_string<char>, std::monostate> &>'
6. /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/variant:1844:5: instantiating function definition 'std::__do_visit<std::__detail::__variant::__variant_idx_cookie, (lambda at /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/variant:586:4), const std::variant<int, std::basic_string<char>, std::monostate> &>'
#0 0x0000000003b8cab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x3b8cab8)
#1 0x0000000003b8a46c SignalHandler(int) Signals.cpp:0:0
#2 0x00007530a7a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007530a7a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007530a7a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007530a7a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007530a7a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007530a7a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x00000000072eac9e clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x72eac9e)
#9 0x00000000073a81a7 clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73a81a7)
#10 0x00000000072d75c1 (anonymous namespace)::TemplateInstantiator::TransformDecl(clang::SourceLocation, clang::Decl*) SemaTemplateInstantiate.cpp:0:0
#11 0x000000000730bf58 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#12 0x000000000732c654 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateInstantiate.cpp:0:0
#13 0x000000000730b643 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#14 0x00000000073116bd clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformReferenceType(clang::TypeLocBuilder&, clang::ReferenceTypeLoc) SemaTemplateInstantiate.cpp:0:0
#15 0x000000000730bbfc clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#16 0x0000000007311e0a clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#17 0x00000000073207f6 clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73207f6)
#18 0x000000000732f345 clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, std::optional<unsigned int>, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x732f345)
#19 0x00000000073309e0 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionTypeParams(clang::SourceLocation, llvm::ArrayRef<clang::ParmVarDecl*>, clang::QualType const*, clang::FunctionType::ExtParameterInfo const*, llvm::SmallVectorImpl<clang::QualType>&, llvm::SmallVectorImpl<clang::ParmVarDecl*>*, clang::Sema::ExtParameterInfoBuilder&, unsigned int*) SemaTemplateInstantiate.cpp:0:0
#20 0x000000000730a22f clang::QualType clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionProtoType<clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionProtoType(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)>(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl*, clang::Qualifiers, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformFunctionProtoType(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
#21 0x000000000730b7b4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#22 0x00000000072f8a51 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*) SemaTemplateInstantiate.cpp:0:0
#23 0x00000000072fa7cd clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#24 0x00000000073069ee clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#25 0x00000000072fa327 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#26 0x00000000072fc058 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (.part.0) SemaTemplateInstantiate.cpp:0:0
#27 0x00000000072fc67b clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x72fc67b)
#28 0x00000000073647d6 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73647d6)
#29 0x00000000073ab910 clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool, clang::VarTemplateSpecializationDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73ab910)
#30 0x00000000073b5e17 clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73b5e17)
#31 0x00000000073baf44 void llvm::function_ref<void ()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)::'lambda'()>(long) SemaTemplateInstantiateDecl.cpp:0:0
#32 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#33 0x00000000073626ba clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73626ba)
#34 0x00000000072eba15 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) SemaTemplateInstantiate.cpp:0:0
#35 0x0000000007339ec4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#36 0x000000000733fe97 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformIfStmt(clang::IfStmt*) SemaTemplateInstantiate.cpp:0:0
#37 0x0000000007339ec4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#38 0x000000000733fe97 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformIfStmt(clang::IfStmt*) SemaTemplateInstantiate.cpp:0:0
#39 0x0000000007339ec4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#40 0x0000000007341964 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x7341964)
#41 0x00000000073af5d9 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73af5d9)
#42 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#43 0x00000000071e24e2 clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x71e24e2)
#44 0x0000000006b9e4a5 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6b9e4a5)
#45 0x0000000007061844 FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, clang::OverloadCandidateSet*, clang::OverloadCandidate**, clang::OverloadingResult, bool) SemaOverload.cpp:0:0
#46 0x00000000070626f4 clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x70626f4)
#47 0x0000000006c159a8 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6c159a8)
#48 0x0000000006c17f0c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6c17f0c)
#49 0x0000000007306ac1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#50 0x00000000072fa327 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#51 0x00000000073396ff clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#52 0x0000000007339ec4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#53 0x0000000007341964 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x7341964)
#54 0x00000000073af5d9 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73af5d9)
#55 0x0000000006bf3399 void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#56 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#57 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#58 0x0000000006be7fcd MarkExprReferenced(clang::Sema&, clang::SourceLocation, clang::Decl*, clang::Expr*, bool, llvm::DenseMap<clang::VarDecl const*, int, llvm::DenseMapInfo<clang::VarDecl const*, void>, llvm::detail::DenseMapPair<clang::VarDecl const*, int>>&) SemaExpr.cpp:0:0
#59 0x0000000006be8619 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-assertions-trunk-20240928/bin/clang-20+0x6be8619)
#60 0x000000000702e36b clang::Sema::FixOverloadedFunctionReference(clang::Expr*, clang::DeclAccessPair, clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x702e36b)
#61 0x000000000706158e FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, clang::OverloadCandidateSet*, clang::OverloadCandidate**, clang::OverloadingResult, bool) SemaOverload.cpp:0:0
#62 0x00000000070626f4 clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x70626f4)
#63 0x0000000006c159a8 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6c159a8)
#64 0x0000000006c17f0c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6c17f0c)
#65 0x0000000007306ac1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#66 0x00000000072fa327 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#67 0x00000000073396ff clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#68 0x0000000007339ec4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#69 0x0000000007341964 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x7341964)
#70 0x00000000073af5d9 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x73af5d9)
#71 0x0000000006bf3399 void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#72 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#73 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#74 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#75 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#76 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#77 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#78 0x0000000006a520af BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
#79 0x0000000006a99ad5 clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a99ad5)
#80 0x0000000006aef60c clang::Sema::DefineImplicitCopyConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aef60c)
#81 0x0000000006bf375b void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#82 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#83 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#84 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#85 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#86 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#87 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#88 0x0000000006a520af BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
#89 0x0000000006a99ad5 clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a99ad5)
#90 0x0000000006aef60c clang::Sema::DefineImplicitCopyConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aef60c)
#91 0x0000000006bf375b void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#92 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#93 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#94 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#95 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#96 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#97 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#98 0x0000000006a520af BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
#99 0x0000000006a99ad5 clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a99ad5)
#100 0x0000000006aef60c clang::Sema::DefineImplicitCopyConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aef60c)
#101 0x0000000006bf375b void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#102 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#103 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#104 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#105 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#106 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#107 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#108 0x0000000006a520af BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
#109 0x0000000006a99ad5 clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a99ad5)
#110 0x0000000006aef60c clang::Sema::DefineImplicitCopyConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aef60c)
#111 0x0000000006bf375b void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#112 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#113 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#114 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#115 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#116 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#117 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#118 0x0000000006a520af BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
#119 0x0000000006a99ad5 clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a99ad5)
#120 0x0000000006aef60c clang::Sema::DefineImplicitCopyConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aef60c)
#121 0x0000000006bf375b void llvm::function_ref<void ()>::callback_fn<clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool)::'lambda'()>(long) SemaExpr.cpp:0:0
#122 0x000000000677ac21 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x677ac21)
#123 0x0000000006be793f clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6be793f)
#124 0x0000000006a4c89c clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6a4c89c)
#125 0x0000000006aeb154 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6aeb154)
#126 0x0000000006e045cd PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#127 0x0000000006e138ba clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6e138ba)
#128 0x00000000069b8129 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x69b8129)
#129 0x000000000663b78a clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x663b78a)
#130 0x000000000664a769 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x664a769)
#131 0x0000000006653087 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6653087)
#132 0x0000000006653549 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6653549)
#133 0x00000000066ff7c2 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x66ff7c2)
#134 0x00000000067004f0 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x67004f0)
#135 0x00000000067013c5 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x67013c5)
#136 0x0000000006702b1a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6702b1a)
#137 0x0000000006615923 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6615923)
#138 0x000000000664b14d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x664b14d)
#139 0x000000000660966e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x660966e)
#140 0x0000000006609e2e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x6609e2e)
#141 0x00000000066115c3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x66115c3)
#142 0x00000000066124ad clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x66124ad)
#143 0x00000000066049ca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x66049ca)
#144 0x000000000479ca99 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x479ca99)
#145 0x000000000471b31e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x471b31e)
#146 0x00000000048825be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0x48825be)
#147 0x0000000000cd452f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0xcd452f)
#148 0x0000000000ccc23a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#149 0x0000000000cd0b7e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0xcd0b7e)
#150 0x0000000000ba0c24 main (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0xba0c24)
#151 0x00007530a7a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#152 0x00007530a7a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#153 0x0000000000ccbcee _start (/opt/compiler-explorer/clang-assertions-trunk-20240928/bin/clang-20+0xccbcee)
Activity
llvmbot commentedon Sep 29, 2024
@llvm/issue-subscribers-clang-frontend
Author: None (Sirraide)
export using Foo = std::variant<int, std::string, std::monostate>;
struct S {
Foo x = std::monostate{};
};
Attempting to compile this asserts on trunk (https://godbolt.org/z/sqWax9eKq). I have not been able to reproduce this w/o modules (yet, but I’ll keep trying). #102353 seems to be the same assertion, but I’m not sure they’re related.
Invocation:
It’s clearly crashing in
b.ccm
, but that might be due to a faulty module being emitted fora.ccm
. I’m unfortunately not that familiar w/ our modules implementation, so I don’t know which one is more likely.Stack trace:
llvmbot commentedon Sep 29, 2024
@llvm/issue-subscribers-clang-modules
Author: None (Sirraide)
export using Foo = std::variant<int, std::string, std::monostate>;
struct S {
Foo x = std::monostate{};
};
Attempting to compile this asserts on trunk (https://godbolt.org/z/sqWax9eKq). I have not been able to reproduce this w/o modules (yet, but I’ll keep trying). #102353 seems to be the same assertion, but I’m not sure they’re related.
Invocation:
It’s clearly crashing in
b.ccm
, but that might be due to a faulty module being emitted fora.ccm
. I’m unfortunately not that familiar w/ our modules implementation, so I don’t know which one is more likely.Stack trace:
[-][Clang] [Modules] Crash on code involving variants[/-][+][Clang] [Modules] Assertion `declaration not instantiated in this scope` in code involving variants and modules[/+]ghost commentedon Sep 29, 2024
ChuanqiXu9 commentedon Sep 29, 2024
How to use this?
Sirraide commentedon Sep 29, 2024
I just tested this w/ libc++ instead of libstdc++, and it works just fine, so there’s something about libstdc++’s implementation of
<variant>
that we’re choking on here.zwuis commentedon Sep 29, 2024
That account seems to be stolen.
Sirraide commentedon Sep 29, 2024
The declaration it’s crashing on is this:
Sirraide commentedon Sep 29, 2024
Ok, after fighting w/
<variant>
for an hour, I’ve managed to reduce this (https://godbolt.org/z/cdqMv1Wco).The bug only triggers if the declaration of
__do_visit()
is the same in both modules. Commands to run to reproduce this:a.ccm
:b.ccm
:Sirraide commentedon Sep 29, 2024
It seems that, while instantiating the lambda in module
B
, we use theTypedefNameDecl
from moduleA
; I don’t know too much about modules, but that seems a bit weird to me... 🤔Sirraide commentedon Sep 29, 2024
Ok, found the issue: we’re trying to find the
TypedefNameDecl
from moduleA
, but theLocalInstantiationScope
only contains theTypedefNameDecl
from moduleB
.Sirraide commentedon Sep 29, 2024
@ChuanqiXu9 I’d appreciate it if you (or someone else familiar w/ our modules implementation) could maybe take a look at this, because I feel like I’ve done pretty much all I can here: I don’t know enough about modules to know where to fix this—alternatively, if you have an idea of how to fix this, then I could also take care of that, but at the moment, I’m fairly lost as to what to do here...
Sirraide commentedon Sep 29, 2024
Decided to look into this a bit more since this is kind of blocking me from doing anything else (because
<variant>
doesn’t compile for me in module-based projects...), so I think I’ve managed to narrow this down further: it seems the lambda’s class type in B somehow has the call operator of the lambda in A, but the entire situation is really weird. Dumping the class type of the lambda in B viagetLambdaClass()
gives:but calling
getCallOperator()
on the same lambda expression returns:Clearly, these are two different
CXXMethodDecls
(and theParmVarDecl
s are also different, which then causes the crash because we can’t find A’s using decl in B).Sirraide commentedon Sep 30, 2024
I think I might have figured something out; I’ll recompile and write a test, and if that works, I’ll open a pr for it shortly.
[-][Clang] [Modules] Assertion `declaration not instantiated in this scope` in code involving variants and modules[/-][+][Clang] [Modules] Clang instantiates the wrong lambda call operator[/+][Clang] Instantiate the correct lambda call operator (#110446)
[clang][modules] Remove the workaround for the lambda issue.