<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87728>87728</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] static constexpr char[] inside lamdba causes link error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
varqox
</td>
</tr>
</table>
<pre>
Clang version: trunk
OS: Linux
[Live example](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGe1wAyeAyYAHI%2BAEaYxBIAzKQADqgKhE4MHt6%2BekkpjgJBIeEsUTFc8XaYDmlCBEzEBBk%2Bfly2mPZ5DDV1BAVhkdF6CrX1jVktQ929RSUSAJS2qF7EyOwcBJgsCQbrANQmsW5oDEM7yAh1AFQ7Q8T72CYaAII3Xg47NcR7AOxWXwAi%2BysTwej3Wm22mD2ByOJzOl2uBFusXuTwAbqg8OgdvxUBAPvs3Dc7uYAGyk2bfX4A4FPYIEHYsJjBCAUkw/EE7TnY1C4kwAVisfL%2BlI5XLFE0cyFOAiGmFUCU%2BcM%2BRIF/OF%2B3VZjMRK1gNFYs5xEwBCWDHeiIJRORbKpeqeYrZfxZsztj0dII481onD5vD8HC0pFQnDc1ms10Wy0h5liPFIBE0nvmAGsQHy%2BQA6DQk2J8gAcAE4zCSNJI86W%2BfpOJI/Ymg5xeAoQBp44n5nBYDBEChUJs6NFyJQ0H36DFgGUzHw6OtiE2IBE6xFgnUAJ6cONL5jEFcAeQi2kqCe4vGHbEEO4YtDXAd4WAiXmAbjEtCbx9IWEZRnEN/feCNVVRTBX0DOVKi8dY6zpNo61oPAImIVcPCwOtETwFh114QDiAiZJMD%2BDZDGAWCjDbPgDGABQADU8EwAB3HcEkYDCZEEEQxHYKQWPkJQ1DrXQWgMEjTEsax9DgptIHmVAEg6V9eFQLDiExID4HmCoqmcCBXFGZpSECYI%2BmKAYWhyVIBB07JkjMhgpn6UpWnaaphgaTwmkGNpDycyYDOmYzbGcizxmc2yjNKNTIxWOYqw4X1SH9QNgw4HZVDzEkAFoSUkHZgGQKUygzMwdggXBCBIPYzFjWZeCPLRZhTNMW29Dga1IdDYkkAqSy4As8z5MxCwLPlYnieL5IbWxm1bG92y7CAkEWAgEnAwcIGHBJ%2B2IUJWFWFL0sy05BOAHYuDzDMuCzXhMHwIglPQPR%2BFY0RxC4EkuMUFR1B/fjSFohCEgwr0fVrH9Ep3cClvpVAqGS1KMqynK8tiAqio8EdonKyrqrbeYEEwJgsBiFlopa9CuEzEl036qnJBJF6vh6uK60SxtJpqz1SA7bs1o2lbudHFBDpOrgWxoWgZznBcf03VdmOl7c9wPBxmNPRgCAvK86zvB8n1oF9mI/Qjv0DfB/0cQDgMu1QwIgn8oKawNYPgxCMFWQNUPQt8sJwpR8M/IjglAaayKYCjqLohimLfB7hCejjpGj97eK%2BkBJ0OlAw0sMSIgkonpNk8aFOiW6VMkhzPM07TXLGPSGHQEKZhMqyOkCxIm7Seu/PUjouhGKvdK7rz6g7%2ByJl7zJ%2B%2BCny7KihQIo4wGYuBhLOBhvasuQQ7jtO86NCKkqboxrgqqm2qcbxgnKAXkmU8zAsNALSQC1iDQvkkV%2BNHLStRvrDgWZbNmZrwDmiABaENea9nWqOLabBOC7ThgdQiW8zoXT0tdEgmJ7qyDYs9eOshE6fUDLoScv0mD/WPAvWK39Qbg3AjsKGq94Eb0QSdZBu8ICo0gejGMZhj4AKvrwdCZgOpcC%2BHyDQZh0xfBem/e%2BXxGYg3Gk2f%2B2NSCpkkB1J%2BmVhZfFiINbq6ZoqxCXmNX%2BJ8kzRTMMYn%2BWNprzCwikZwkggA%3D%3D%3D)
Minimal code example:
```cpp
template <const char* str>
struct Str {};
template <const char* str>
void foo(Str<str>&&) {}
int main() {
foo([] {
static constexpr char str[] = "str";
return Str<str>{};
}());
}
```
Linking errors:
```
/opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-4a4736.o:(.debug_info+0x70): undefined reference to `main::$_0::operator()() const::str'
/opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-4a4736.o:(.debug_info+0x113): undefined reference to `main::$_0::operator()() const::str'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Execution build compiler returned: 1
```
Expected behavior: no errors.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUN0mTgzivv4a-UN0FhgA59MFmSQghhGyEXKZYHENYwxKWX_8K0j3fzJs5vMs7fCmXgyVZ1mZZ8uo6JjnG39QCUQvlw2ubqKi-X171LPoPvwiHbzn1ckK_cFXHRU5xkG6qNk8oRqEYaB0nwDbO2_4N-JkXaBu_MI17LytTTC0UCkhR05Q1xUEKaBTQSBH6Rdp8FRWZAdxIcdBytySCGnqGC1vuodvtXWTKGTqEaAs11pYD6O1VGZpjhxoTitDutMa00QAPZGk0tqvCoY59xr5CuZcQgkaB8hOEZ7guO2i-oOaejs2GsIoOSyi70G7dNkmXN3jqFOMRwpV2bqDB1yvMdnDAcHDhWqfAAiCoem6PdDgaNlSexIhU3lw3wozDSVI-yAbpWK3PJy2Qrp6rZKmM1FFFKJlp7ukAsv1toSgXFsFLlISaIFdX9nFJGnsJlofj-Qg3R_DURHWwugBtSC3bfgV3dlY7i0JRTXGAEQs1W7Slkwhk14O6zl0JL-6Cgwit3rl2MJ4PG-pThx-ckwGQKQAN1ma0UtAira2v7amD_pNIFglf_RnB_avmlEBsXbgaEuDfrzzktb2rq2u33jyQDM9JRwFNVcVT7rIyn3TwEtf37XxQqi-uW01lgkGzYLzKtLN8nhGBOf8d9MnXljYvuMvtYR4Mluw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