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

    <tr>
        <th>Summary</th>
        <td>
            [clang] [Interp] assertion failure on lambda capture of lambda (-fexperimental-new-constant-interpreter)
        </td>
    </tr>

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

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

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

<pre>
    Given:

```c++
void wrapper() {
  constexpr auto f = []() constexpr {
    return 0;
 };

  constexpr auto g = [f]() constexpr {
    return f();
 };
  static_assert(g() == f());
}
```

With `-fexperimental-new-constant-interpreter` clang crashes evaluating the declaration of `g`:

```
clang++: /root/llvm-project/clang/include/clang/AST/APValue.h:553: clang::APValue& clang::APValue::getStructField(unsigned int): Assertion `i < getStructNumFields() && "field index OOB"' 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 -fexperimental-new-constant-interpreter <source>
...
```

(see: https://godbolt.org/z/nz8v5sffc )
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVUFv4zYT_TX0ZUBBpmxLOvjgrOMPH1B0A6RojwVFjSQ2FCmQw8S7v74gbSfpdncRFBAEcDTzhnzvDSVD0KNF3LPtHdseVzLS5Pw-IE3LqnP9l_3_9DNaVh1YeWTl7b0rL49i4i49OfrsdA8vXi4LeiYaJlpg9fUbgHI2EJ4XDzKSgwFYdYRL12vyW8a7MgCPFL2FklW3IKuPr4sfwI83-OGj-MMl6_tdAAJJ0upPGQJ6YqIZbyesjqnTrfod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