<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/133981>133981</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wundefined-inline and linking issue
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
boguscoder
</td>
</tr>
</table>
<pre>
```
void foo() {
auto lambda = [](auto&& unused) {
struct Test {
Test(...) {}
~Test() {}
} test;
};
lambda(42);
}
template <typename ... T>
void fooT() {
auto lambda = [](auto&& unused) {
struct Test {
Test(...) {}
~Test() {}
} test;
};
lambda(42);
}
int main() {
foo();
fooT<int, char, double>();
return 0;
}
```
yields
```
<source>:15:9: warning: inline function 'fooT()::(anonymous class)::operator()(int &&)::Test::Test' is not defined [-Wundefined-inline]
15 | Test(...) {}
| ^
<source>:17:9: note: used here
17 | } test;
| ^
<source>:16:9: warning: inline function 'fooT()::(anonymous class)::operator()(int &&)::Test::~Test' is not defined [-Wundefined-inline]
16 | ~Test() {}
| ^
<source>:17:9: note: used here
17 | } test;
| ^
2 warnings generated.
ASM generation compiler returned: 0
<source>:15:9: warning: inline function 'fooT()::(anonymous class)::operator()(int &&)::Test::Test' is not defined [-Wundefined-inline]
15 | Test(...) {}
| ^
<source>:17:9: note: used here
17 | } test;
| ^
<source>:16:9: warning: inline function 'fooT()::(anonymous class)::operator()(int &&)::Test::~Test' is not defined [-Wundefined-inline]
16 | ~Test() {}
| ^
<source>:17:9: note: used here
17 | } test;
```
Link https://godbolt.org/z/8ef585x3x
This does work in trunk gcc and msvc.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVsuO2zYU_ZqrzcUIFGlZ0kILxROv2lUH6JoiaZkdijT4mGS6yLcXtOR5JXGAKdoCRQQBpHif55xLwzwEPVmleqg_QH1b8BSPzvejm1IQTipfjE4-9rAl60uGB6clHpwD2gLtEJoPQAZERJ6iQ8PnUXIEdotLSqBtNgDdAt1isiko-ToOMUSfRMQ7FeLlPO-BtmVZXpyb2yd_xC-r_RtGaG4xZiu7FMjW5WPpDmi7oUC75XCJBTJENZ8MjwqB7eLjSVk-KyzLEu-AfXwB_O6fRb4-3yPgncgRr4PXNuLMtX2N7Unm5yxnAthO2wh0h-LIfV6lS6NRmac37l7F5C2SV-VeTBOQ4VErI8Oyf2tlu-CSF-fMbKhqYEMHbMBP3Fttp7zV1mir8JCsiNpZBNo8iwRsyC9tuXX2cXYpoDA8hCeTOynPo_OrO20zEYtkTz5nxp93tEEd0LqIUh20VTLrffN7suvnzdJRnoAzB1WN0OzwR8KuEu4Q6o_fgN5coFsXVV7zOOFRebVWaV5U-XoSrqXe_sesfnkfrdtXtF69F_8CqfTCXsBJ2QxfyRLIMPz26-Ug8yjcfNJG-fViKJmr_t9G_Ycjfnn-lirf0-N68p_D_o5hf_OL_Yu293iM8RTOzOyB7icnR2di6fwEdP8n0H2rDnVbf2afl5i7ow4onQr4yfl71BajT_YeJyGQW4lzeBAlFrJnsmMdL1RfNRtWs47Sqjj2XdVVRIy06uimbXhXjWwrGDmMFaWjkNtC95TQmmxIRQltSFWSsaJ8e2gEa8k4igNsiJq5NqUxD3Pus9AhJNVXjHVtVRg-KhMu_4N8n71uxjQF2BCjQwzPcVFHo_qv1TrjMNreazvhOXmRvOnfEKXjMY2lcDPQfU65Ljcn7_5QIgLdn0MD0P3a2kNP_woAAP__XnSoLg">