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

    <tr>
        <th>Summary</th>
        <td>
            Clang crashes during compilation - related to auto-this feature
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    The minimal code:

```cpp
void repro(unsigned* words)
{
    auto my_repro = [&](this auto& recurse) -> void
    {
        if (*words)
        {
            words += 1;
 recurse();
        }
    };
    my_repro();
}
```

The command line:

clang-18 tmp.cpp --std=c++2b

The crash info:

0.      Program arguments: /usr/lib/llvm-18/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name tmp.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home -fcoverage-compilation-dir=/home -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include --std=c++2b -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/tmp-b9cf32.o -x c++ tmp.cpp
1.      <eof> parser at end of file
2. Per-file LLVM IR generation
3.      tmp.cpp:3:21: Generating code for declaration 'repro(unsigned int *)::(anonymous class)::operator()'
4. tmp.cpp:6:9: LLVM IR generation of compound statement ('{}')
 #0 0x00007f9e75dbd716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94716)
 #1 0x00007f9e75dbb6d0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd926d0)
 #2 0x00007f9e75dbdddb (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd94ddb)
 #3 0x00007f9e74c09520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f9e7e44d06a (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1df506a)
 #5 0x00007f9e7e450ab0 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1df8ab0)
 #6 0x00007f9e7e4502ea clang::CodeGen::CodeGenFunction::EmitCompoundAssignmentLValue(clang::CompoundAssignOperator const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1df82ea)
 #7 0x00007f9e7e40828f clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1db028f)
 #8 0x00007f9e7e3fab4b clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1da2b4b)
 #9 0x00007f9e7e55163b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ef963b)
#10 0x00007f9e7e551eb1 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ef9eb1)
#11 0x00007f9e7e55155d clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ef955d)
#12 0x00007f9e7e552942 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1efa942)
#13 0x00007f9e7e5519ba clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ef99ba)
#14 0x00007f9e7e55ceac clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f04eac)
#15 0x00007f9e7e5b5e9f clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f5de9f)
#16 0x00007f9e7e5b6967 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f5e967)
#17 0x00007f9e7e5d77c5 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f7f7c5)
#18 0x00007f9e7e5d1140 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f79140)
#19 0x00007f9e7e5c44b3 clang::CodeGen::CodeGenModule::EmitDeferred() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f6c4b3)
#20 0x00007f9e7e5c200b clang::CodeGen::CodeGenModule::Release() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f6a00b)
#21 0x00007f9e7e66e698 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2016698)
#22 0x00007f9e7e5a7020 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4f020)
#23 0x00007f9e7d1d7fc6 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb7ffc6)
#24 0x00007f9e7f008ab5 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29b0ab5)
#25 0x00007f9e7ef82084 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x292a084)
#26 0x00007f9e7f08325e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2a2b25e)
#27 0x000055d912c04d55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x12d55)
#28 0x000055d912c02155 (/usr/lib/llvm-18/bin/clang+0x10155)
#29 0x000055d912c01316 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0xf316)
#30 0x000055d912c0ebf6 main (/usr/lib/llvm-18/bin/clang+0x1cbf6)
#31 0x00007f9e74bf0d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#32 0x00007f9e74bf0e40 call_init ./csu/../csu/libc-start.c:128:20
#33 0x00007f9e74bf0e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#34 0x000055d912bfebc5 _start (/usr/lib/llvm-18/bin/clang+0xcbc5)
clang-18: error: unable to execute command: Segmentation fault
clang-18: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.6 (++20240518023229+1118c2e05e67-1~exp1~20240518143321.130)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWl1z27bS_jX0DQYaEvy-8IUsRWnmbftmYre91IDAUkYDAhwAdOSb_vYzICVLoB239uickzkZj0KBi93nWSx2VwSptWKnAK6j_CbK11d0cPfaXLt7YYXtHntqba-Nu2o0f7y-uwfUCSU6KhHTHKJ0GcXrKD5-FvH0x_p-GnnQgiMDvdERqQY1muIRWaJv2nAbkfowsbyZLhBCiA5Oo-5xO05DUbpGHhoponwdkcoDG0UiUiADbDAWIlIjHKUfkDd3UhRo9f9EiyJSRWQZWj_efibv_42iKCI3HkgSpUeRJ9OV15PezFWtz3GsA4Ejt9ncpzlPbjz3rXc9011HFUdSqLnrmaRqh5MKua5fsL5HGFvHo3TNPHRyQ5pnygy190ioVs9UxYuJw2ejd4Z2iJrd0IFyNkqXKCKbwZqIbKRo_Kd86HBSRWTTCBWRzQgDYcYShJ0RvQS0r4ptkeGeYSnUsMc7NSAMnXBYN38i3BmQdI-plAjzoeu5MIhihLmwtJGAWwOAMJNADabW4QZabQA3lH0FxU9yI5IHMKIVYMZhRg3HD1QOgBXtwCLcUaFwK-Q0cHKVx6AZdUIr3GkOEvWCIdwLhiU8gERk-iIs7gUg3LWGdoB7LZQDE6XrEX3bUXePwRilEW7bHjOtnKHMRelaK4RbpbHRg-JC7bCXRbhjWllnBua0wVQKaj3MdlDfhOLYeWI2StcEYUfNDhxm_eAdiosMYTcoGAd2oMB4wByaYbcD428JtYvS9Y43CLfjOGa664WcWHLhYUdkc687QLhl-gEM3cF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