<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56168>56168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Stack dump on use of injected-class-name in a templated friend declared in a base type
</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>
See https://godbolt.org/z/cK7xEMj96.
```C++
struct base {
friend auto downcast_guide(base, auto);
};
template<class T> struct derived : base {
friend auto downcast_guide(base, auto) { return derived{}; }
};
derived<int> d;
decltype(downcast_guide(base{}, 0)) d2;
```
```
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++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++2b -pedantic -Wall -Wextra -stdlib=libc++ <source>
1. <eof> parser at end of file
2. <source>:10:37: LLVM IR generation of declaration 'd2'
3. <source>:10:37: Generating code for declaration 'd2'
#0 0x000055f854af8a0f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055f854af6804 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x36f6804)
#2 0x000055f854a384a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f19715d03c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#4 0x000055f854fbb017 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bbb017)
#5 0x000055f854fba0cd clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bba0cd)
#6 0x000055f854fbb034 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bbb034)
#7 0x000055f854eba885 clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3aba885)
#8 0x000055f854f6256c clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b6256c)
#9 0x000055f854f7dc85 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b7dc85)
#10 0x000055f854f7e503 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b7e503)
#11 0x000055f854f8471d clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5868) CodeGenModule.cpp:0:0
#12 0x000055f855b13ad1 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#13 0x000055f855b07232 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4707232)
#14 0x000055f856a5e144 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x565e144)
#15 0x000055f855b1231d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x471231d)
#16 0x000055f8554eabf1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40eabf1)
#17 0x000055f855483172 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4083172)
#18 0x000055f8555b9693 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41b9693)
#19 0x000055f8526447f4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12447f4)
#20 0x000055f85263d53d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#21 0x000055f855314145 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
#22 0x000055f854a38a93 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3638a93)
#23 0x000055f855316218 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+++0x3f16218)
#24 0x000055f8552e4e93 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ee4e93)
#25 0x000055f8552e59d3 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ee59d3)
#26 0x000055f8552ee7af clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3eee7af)
#27 0x000055f8526423ee clang_main(int, char**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12423ee)
#28 0x00007f197107e0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#29 0x000055f85263d14a _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x123d14a)
clang-15: error: clang frontend command failed with exit code 139 (use -v to see invocation)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWV1z2zYW_TX0C4YafpN60IMiO9l0k6038qSPGhAAJbYQwQFAR-6v3wuAtARZdptUnZ2d9cgSCYAX55x7cfHBWtCnxZoxtNO6V0G6DJL38NkKWguuZ0Ju4e53-Cf_LA93n3-dF7Mgug2i5fhdRO6zCpJ35mNLlZYD0ajGiqGgHAsRamTLOorwoAWi4ltHsNKb7dBSFiSVaRwkK1sbJPMgHR8Lytvjtf3WbN9zrFmQrgjHSqGHIL1DY5-UyfaRUQRM_lL_5jkkmR5kN9k0liwYZH5eATe1TVdtpw0u-tyAMsL1U286u9y7sw8YIiMAYKDJ0fok9EX13e39p7vlGpQY6n2rEUb1sAUKvZAaAeMzB7d6N9QzIvZww_nj9BP2UvzKiIbbVqmBKbhAGFRrO8IHypDeMUQkVjuQl_ymJSZWth46koIwpUB8JQbpis2T4CJBWnAYRXLokCKy7fUYRWsNRhAd9r1BZosiqJrfS7GVeI-w3A571mkDHAEU0RtkgLpvOZMhO_RcSCZNGcfdNoQg6H6Du7rtpjIXmCjc0m9YNmEGVygUxhjue2Ny0P2gZwqFeyMACsNDVYRY7UP11Gl8CNJbcCXjKFxD3ZaQUAvByQ5DF-ntm5hMY9XhXu2ERmFDBFSEtMXbTijdEuiy6URo1fSLlYawuSUOelKjsGcUd1CHwl8wByi_sANIbxvytoa28D02h9BfjQ5I75yksZEUiploTEj2WComEdbIDAfRoAaAu5bJ2PJoIF3GEXylpfHAp09fP6OPX9CWdUxi3YrOPG4CG4-3QVJC1CalM5e-be7DaKbbIiIgthoh3zAGt2mEokMEf3neVHmGmwpHDbqX4CAbSQ8mHNfttsP8HxB63HihehQtDZKlGVCuSs1Ib-Itsv_PtuMz20UVZcgODQjNdKmelLtYcYa7of-5c9agh6FTcAnxzYWJN0geSfVXghU-0SEtLAKTCp4hJj7EtMpwhVYmfr4wIh6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