<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70604>70604</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Deducing this lambda causes crash when using explicit reference capture
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          onelumin
      </td>
    </tr>
</table>

<pre>
    Compiler Explorer: [https://godbolt.org/z/6vMEhdGqx](https://godbolt.org/z/6vMEhdGqx)

This little example causes the crash:
```
auto dothing(int num)
{
 auto fun =  [&num](this auto&& self) -> void {
        auto copy = num;
    };

    fun();
}
```

Interestingly if the signature of fun is changed to `[&](this auto&& self) -> void`, it works fine even though in both cases num is captured by reference.

Note that there is another issue at play since changing the explicit capture to the & catch all does not fix the code that I reduced this example from. Instead I still get a crash but this time a "cannot compile this l-value expression yet" from codegen.

```
clang++: /root/llvm-project/clang/lib/AST/ASTContext.cpp:2299: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"' failed.
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-assertions-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++23 <source>
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      <source>:3:16: Generating code for declaration 'dothing(int)::(anonymous class)::operator()'
 #0 0x00000000037569a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37569a8)
 #1 0x000000000375466c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x375466c)
 #2 0x000000000369d018 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007efe146d7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007efe1419a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007efe14179859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007efe14179729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007efe1418afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000006db4355 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6db4355)
 #9 0x0000000006da2c27 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6da2c27)
#10 0x0000000006db570b clang::ASTContext::getPreferredTypeAlign(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6db570b)
#11 0x0000000006db603b clang::ASTContext::getDeclAlign(clang::Decl const*, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6db603b)
#12 0x0000000003e20310 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e20310)
#13 0x0000000003e2165b clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#14 0x0000000003e21900 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e21900)
#15 0x0000000003a64e07 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a64e07)
#16 0x0000000003a78d87 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a78d87)
#17 0x0000000003a721d5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a721d5)
#18 0x0000000003a786bc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a786bc)
#19 0x0000000003ad7c96 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ad7c96)
#20 0x0000000003aeacda clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aeacda)
#21 0x0000000003b4bcc3 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b4bcc3)
#22 0x0000000003b46dc5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b46dc5)
#23 0x0000000003b51cee clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b51cee)
#24 0x0000000003b546f3 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b546f3)
#25 0x00000000049c1faa (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#26 0x00000000049c0975 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c0975)
#27 0x0000000005ecf3b9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5ecf3b9)
#28 0x00000000049c0068 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c0068)
#29 0x0000000004223d29 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4223d29)
#30 0x00000000041a4e0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41a4e0e)
#31 0x0000000004302cfe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4302cfe)
#32 0x0000000000bf4a76 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbf4a76)
#33 0x0000000000bec33a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000000004000359 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
#35 0x000000000369d4c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x369d4c4)
#36 0x000000000400094f 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
#37 0x0000000003fc8955 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fc8955)
#38 0x0000000003fc93bd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fc93bd)
#39 0x0000000003fd12e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fd12e5)
#40 0x0000000000bf1f1c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbf1f1c)
#41 0x0000000000aeb0f1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaeb0f1)
#42 0x00007efe1417b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#43 0x0000000000bebe1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbebe1e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWtFy27iS_Rr6BSUXCVIU-eAHWbKznsrMpuJs9lEFgk0JGxDgAKAjz9dvAaAkgrYTO2XN3Fs35bhMsNk456DZaAIgWrOtALiK5tfRfH1BerOT6koK4H3LxEUl68erlWw7xkGhm33HpQIVpUsUza93xnQ6SpcRvo3w7VbWleTmUqpthG__ivBt_vD7za7-8Oc-mq8jXLzeHJdRvI7ipf_9Zcc04swYDgj2pO04IEp6DRqZHSCqiN5Zt_6RPB5-3CXpjUS1NDsmthEumDBI9O2pg8W1_wM5w6YXKErXyJKLcG4tHXJjEViLCOcRzpEG3kS4RLMovUEPktXo5Gj45_xR2T06h9ZTOrKIFuvj9am16UWECwvueG-xfpaW_30nDCjQhoktf0SscXLY8SSmV4Bk4wgxjeiOiC3UyEhkXThyr2Rm7fEKMYO-S_VNo4YJQPAAApmd7Lc7xASqpNkhSuyAiL51HZLOQqhR9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