<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85373>85373</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][crash-on-valid] Crash in frontend with `std::source_location::current().column()` in deduction guide
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LocalSpook
</td>
</tr>
</table>
<pre>
The following code crashes Clang, compiling with `-std=c++20 -emit-llvm -Xclang -disable-llvm-passes`:
```cpp
#include <source_location>
template <int>
struct S { S(const char *); };
template <int M>
S(const char(&)[M]) -> S<std::source_location::current().column()>;
void f() {
S{"If you remove this line, no crash happens."};
}
```
Link: https://godbolt.org/z/jPbb5Kr1P.
It does not crash on versions 17.1.0 and earlier.
I don't believe this is related to #67134, because this has a completely different backtrace.
It also gives an error:
```text
<source>:10:5: error: cannot compile this scalar expression yet
10 | S{"If you remove this line, no crash happens."};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Backtrace:
```text
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++20 -emit-llvm -Xclang -disable-llvm-passes <source>
1. <eof> parser at end of file
2. <source>:9:6: LLVM IR generation of declaration 'f'
3. <source>:9:6: Generating code for declaration 'f'
#0 0x00000000036774c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x36774c8)
#1 0x0000000003675614 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3675614)
#2 0x00000000035bfc48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fbcd4242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000002f3a418 llvm::UndefValue::get(llvm::Type*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2f3a418)
#5 0x0000000003db06e6 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#6 0x0000000003db2a53 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3db2a53)
#7 0x0000000003d53f9e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d53f9e)
#8 0x0000000003d6e83b clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d6e83b)
#9 0x000000000397f0be clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x397f0be)
#10 0x0000000003985319 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3985319)
#11 0x00000000039e2fc4 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39e2fc4)
#12 0x00000000039ef422 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39ef422)
#13 0x0000000003a463bb clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a463bb)
#14 0x0000000003a42105 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a42105)
#15 0x0000000003a42db0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a42db0)
#16 0x0000000003a4ae67 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#17 0x0000000003ecf3d6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#18 0x0000000003ec04f9 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ec04f9)
#19 0x0000000005d7496c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d7496c)
#20 0x0000000003ecce75 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ecce75)
#21 0x0000000004162361 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4162361)
#22 0x00000000040e831b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40e831b)
#23 0x00000000042449a3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42449a3)
#24 0x0000000000c32d06 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc32d06)
#25 0x0000000000c2bb8d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000000003f144f9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#27 0x00000000035c0073 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35c0073)
#28 0x0000000003f14719 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#29 0x0000000003edc457 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3edc457)
#30 0x0000000003edce0d 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+++0x3edce0d)
#31 0x0000000003ee6b6c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ee6b6c)
#32 0x0000000000c30121 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc30121)
#33 0x0000000000b26194 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xb26194)
#34 0x00007fbcd4229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007fbcd4229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000000000c2b36e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc2b36e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1v2zzS_TXMDSFDor7si1w4dtI3z9tii7rb3TuDIimbTylSIKnU3ov97QtSsiO6TtoE2sUCG_QjpsjhOWdGMyPK2Bi-k4zdgvwO5Osb3Nm90rcfFcFi0yr1_aZS9Hj7dc9grYRQP7jcQaIog0Rjs2cGrgSWO4BWkKim5cJd_8HtHoIijoylIF0TgO4Auk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