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

    <tr>
        <th>Summary</th>
        <td>
            `inline function ... is not defined` points to the definition, then get 'undefined reference'
        </td>
    </tr>

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

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

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

<pre>
    This is a regression introduced in Clang 15.

```cpp
template <typename F>
void foo()
{
 [&](auto)
    {
        struct Guard { ~Guard() {} };
        Guard guard;
    }(42);
}

int main()
{
 foo<int>();
}
```
[Godbolt link](https://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:2,endLineNumber:14,positionColumn:2,positionLineNumber:14,selectionStartColumn:2,selectionStartLineNumber:14,startColumn:2,startLineNumber:14),source:'template+%3Ctypename+F%3E%0Avoid+foo()%0A%7B%0A++++%5B%26%5D(auto)%0A++++%7B%0A++++++++struct+Guard+%7B+~Guard()+%7B%7D+%7D%3B%0A++++++++Guard+guard%3B%0A++++%7D(42)%3B%0A%7D%0A%0Aint+main()%0A%7B%0A++++foo%3Cint%3E()%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:54.67015022860875,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang_trunk,deviceViewOpen:'1',filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:c%2B%2B,libs:!(),options:'',paneName:Clang,selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:Clang,t:'0')),header:(),l:'4',m:46.40234948604993,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+15.0.0',editorid:1,fontScale:13,fontUsePx:'0',j:2,paneName:'Clang+output',wrap:'0'),l:'5',n:'0',o:'Clang+output',t:'0')),header:(),l:'4',m:53.59765051395007,n:'0',o:'',s:0,t:'0')),k:45.32984977139125,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)

Clang says:
```none
<source>:6:24: warning: inline function 'foo()::(anonymous class)::operator()(int)::Guard::~Guard' is not defined [-Wundefined-inline]
        struct Guard { ~Guard() {} };
 ^
<source>:7:15: note: used here
        Guard guard;
 ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-a1895d.o: in function `operator()<int>':
<source>:8: undefined reference to `foo<int>()::{lambda(auto:1)#1}::operator()<int>(int) const::Guard::~Guard()'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
```
While GCC and MSVC accept this code.

Tested on Clang 15, and on trunk commit `a564048899a1a1de526a02cfd1a5d691ec31bafd`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV81ypDgSfhrVRVEECMTPoQ4u7Oo97PZsRM_OHCcEyqrStJAIJPxz2WffkAQusHGPo3ccFRhSmSkpM79PKWaMuCiAA6JHRO93bLRXPRz-oeXLUbL2e83srtH85fDrVRgsDGZ4gMsAxgitsFB20HxsgWOhcC2ZuuCERii-R_Hd9Mzj8Gv7PkgsdL1kFjBKa_vSg2Id4BNKH8LwoxYcn7VGpESkmpwUx_CC3TJJjug9IiUbrX5VwRjjm9r0Z-wwthZ_GdnA3Sj-r38Nrr16cY9RcY_SN4bB4uKVl2NOl5QZcdPOcidbbFgoizsm1Pb63cbSWijr9hs03vuZQzZ90uMXzRstLZZCfQ97v1rbG5TeIXJC5HRp2-gSdCI9XLwwvf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