<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54590>54590</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Modules] Stack dump on use of downcast facility
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JohelEGP
</td>
</tr>
</table>
<pre>
That is, the hidden friend declared in a dependent base type and defined in a dependent derived type.
See https://godbolt.org/z/3qd4Yb8a4.
`mod.cpp`:
```C++
export module mod;
export template<class>
struct downcast_base {
friend auto downcast_guide(downcast_base);
};
export template<typename Target, class T>
struct downcast_child : T {
friend auto downcast_guide(typename T::downcast_base) { return Target(); }
};
export struct x : downcast_base<x> { };
export struct y : downcast_child<y, x> { };
```
`test.cpp`:
```C++
import mod;
int main() {
downcast_guide(y{});
}
```
Output:
```
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: /opt/compiler-explorer/clang-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -std=c++2b -fmodules -fbuiltin-module-map -fmodule-file=/app/build/mod.pcm -o CMakeFiles/test.dir/test.cpp.o -c /app/test.cpp
1. <eof> parser at end of file
2. /app/test.cpp:2:5: LLVM IR generation of declaration 'main'
3. /app/test.cpp:2:5: Generating code for declaration 'main'
#0 0x0000564ecdfe1baf PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000564ecdfdf9e4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35df9e4)
#2 0x0000564ecdf18df8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fae5483c3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#4 0x0000564ed090dce3 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f0dce3)
#5 0x0000564ed0900da2 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f00da2)
#6 0x0000564ed0900ef5 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f00ef5)
#7 0x0000564ece4cc9d8 (anonymous namespace)::X86_64ABIInfo::getIndirectReturnResult(clang::QualType) const TargetInfo.cpp:0:0
#8 0x0000564ece4ed843 (anonymous namespace)::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const TargetInfo.cpp:0:0
#9 0x0000564ece5fd1a5 clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, bool, bool, llvm::ArrayRef<clang::CanQual<clang::Type> >, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bfd1a5)
#10 0x0000564ece5ff946 clang::CodeGen::CodeGenTypes::arrangeFreeFunctionType(clang::CanQual<clang::FunctionProtoType>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bff946)
#11 0x0000564ece47e7b5 clang::CodeGen::CodeGenTypes::ConvertFunctionTypeInternal(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a7e7b5)
#12 0x0000564ece47f9e6 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a7f9e6)
#13 0x0000564ece4471d3 clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a471d3)
#14 0x0000564ece657586 EmitFunctionDeclPointer(clang::CodeGen::CodeGenModule&, clang::GlobalDecl) CGExpr.cpp:0:0
#15 0x0000564ece657830 EmitDirectCallee(clang::CodeGen::CodeGenFunction&, clang::GlobalDecl) (.isra.1032) CGExpr.cpp:0:0
#16 0x0000564ece677721 clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c77721)
#17 0x0000564ece677753 clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c77753)
#18 0x0000564ece677916 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c77916)
#19 0x0000564ece691928 (anonymous namespace)::ComplexExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprComplex.cpp:0:0
#20 0x0000564ece696846 (anonymous namespace)::ComplexExprEmitter::Visit(clang::Expr*) CGExprComplex.cpp:0:0
#21 0x0000564ece696d90 (anonymous namespace)::ComplexExprEmitter::Visit(clang::Expr*) CGExprComplex.cpp:0:0
#22 0x0000564ece698504 clang::CodeGen::CodeGenFunction::EmitComplexExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c98504)
#23 0x0000564ece65deb1 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c5deb1)
#24 0x0000564ece6762c6 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c762c6)
#25 0x0000564ece39f3dc clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x399f3dc)
#26 0x0000564ece3a504c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a504c)
#27 0x0000564ece3f6113 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39f6113)
#28 0x0000564ece3ffc9c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39ffc9c)
#29 0x0000564ece4473b8 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a473b8)
#30 0x0000564ece4444f5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a444f5)
#31 0x0000564ece444c33 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a44c33)
#32 0x0000564ece44b051 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5419) CodeGenModule.cpp:0:0
#33 0x0000564ecefac351 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#34 0x0000564ecefa0fd2 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45a0fd2)
#35 0x0000564ecfe71144 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5471144)
#36 0x0000564ecefaab9d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45aab9d)
#37 0x0000564ece99e071 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f9e071)
#38 0x0000564ece936fa2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f36fa2)
#39 0x0000564ecea6bed3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x406bed3)
#40 0x0000564ecbba6044 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11a6044)
#41 0x0000564ecbba1fdd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#42 0x0000564ece7d1c35 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#43 0x0000564ecdf193e3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35193e3)
#44 0x0000564ece7d3d08 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dd3d08)
#45 0x0000564ece7a65ba clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3da65ba)
#46 0x0000564ece7a70ff clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3da70ff)
#47 0x0000564ece7afb65 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dafb65)
#48 0x0000564ecbad1742 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x10d1742)
#49 0x00007fae542ea0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#50 0x0000564ecbba1b5a _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11a1b5a)
clang-15: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 460e1bd66e5757be06efc5bbb5f686fd8c119a02)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
clang-15: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-15: note: diagnostic msg: /tmp/test-1f07f4.cpp
clang-15: note: diagnostic msg: /tmp/test-1f07f4.cache
clang-15: note: diagnostic msg: /tmp/test-1f07f4.sh
clang-15: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlW11z6rgZ_jXkRgPjb8NFLgj52OxkmzShZ9srRpZkcI-xXFnOgf76vpIMWA6BJMfd7Ux3khOQ5FfP837b1iacbi_nKyxRVg28GZIrhlYZpaxAqchYQRFlJMeCUZQVCMO3EgZZIVGCK4bktmQI61VpVrxdRJnIXmFYrRsNnOuBM31hsIOUZTXwpwPvFn6WnCY8lyMulvDt3_Dr_4sG_0jGOGiuGUTOmtMRKUv4pK7bjZqf2cC7Uj96lG1KLiSC9XXO1J-B38xY85KtyxxLNvBnwK8CNDdmvpKiJoCc_ygIruRC8xzEjQy0UwuuJT8sWtYZZQNvbF018CaHvePrsziUkgq8ZmiOxZJJZQ4NDc3fBUdWWU4RaATNP4zxsI3SpD_tYlaCkGCyFsUeydhwQYrGaT4Nwo0GZYv2ZxsgosW3L7cv3NoXaoJw5VZp4-jley_Yf5Wskh_zlWy985W9uAy8do2zwnBuK_WNIrdqEpB0zHwM1WMty1q-RWO-Pj3cTF9uUFUn60xC_CT1Egxg3IN3gyWTqzoZEb6GL3n-uvszLAX_JyNgq9usqmoG0XyrIzM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