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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Destructor definition is not compiled for local class in generic lambda initializing a variable template
        </td>
    </tr>

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

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

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

<pre>
    ```c++
template <class>
constexpr auto f{[] (auto) {
    struct OnScopeExit { ~OnScopeExit() {} }
    pending;
}};

int main() {
 f<int>(0);
}
```

See https://compiler-explorer.com/z/6vneqf93z.

Warning and linker error since Clang 15:
```console
<source>:3:26: warning: inline function '(anonymous class)::operator()(int)::OnScopeExit::~OnScopeExit' is not defined [-Wundefined-inline]
    3 |     struct OnScopeExit { ~OnScopeExit() {} }
 |                          ^
<source>:4:5: note: used here
    4 | pending;
      |     ^
1 warning generated.
ASM generation compiler returned: 0
<source>:3:26: warning: inline function '(anonymous class)::operator()(int)::OnScopeExit::~OnScopeExit' is not defined [-Wundefined-inline]
    3 |     struct OnScopeExit { ~OnScopeExit() {} }
 |                          ^
<source>:4:5: note: used here
    4 | pending;
      |     ^
1 warning generated.
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-eeceaa.o: in function `auto f<int>::{lambda(auto:1)#1}::operator()<int>(int) const':
<source>:5:(.text._ZNK1fIiEMUlT_E_clIiEEDaS1_[_ZNK1fIiEMUlT_E_clIiEEDaS1_]+0x14): undefined reference to `f<int>::{lambda(auto:1)#1}::operator()<int>(int) const::OnScopeExit::~OnScopeExit()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVk-vozYQ_zTOZRQENgRy4EBegrSq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