<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55560>55560</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failure to compile std::u16string from libstdc++ 12.1 in c++20 mode
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
patstew
</td>
</tr>
</table>
<pre>
I'm getting:
```
error: undefined symbol: void std::__cxx11::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t> >::_M_construct<char16_t const*>(char16_t const*, char16_t const*, std::forward_iterator_tag)
```
compiling the following simple test case:
```
#include <string>
#include <string_view>
// static std::u16string _clang_string_workaround(const char16_t* a, const char16_t* b) { return {a, b}; }
extern std::u16string_view sv;
std::u16string_view sv{u"test"};
std::u16string print() { return std::u16string(sv); }
int main(int, char**) { std::u16string s = print(); }
```
on clang 13 and 14.0.0, with `clang++ -std=c++20 -o test test.cpp`. It works fine with `-std=c++17`. Bizarrely, it also works if you simply uncomment the `_clang_string_workaround` line which isn't even called. It looks like libstdc++ moved that `_M_construct` function into a separate file recently, which might be related.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VNtuozAQ_RryMioCAyF94CFpWqkP-w3IwADeGoxskzT79Ts2aZNs0pUQ-HJmzpkblWpOxXvA8gE6tFaMXZBsg2gfRNtgHZ0fv0WtlaZLmMcGWzFiA-Y0VEq6s4MStLWNM062ZVl_fsbxsqm4EXVprPa-X-qe63hd2oC9XAzcYWk1F9ZcQ5LXGxSXUtXcOhXXGHC4hfdXWauRqObaXmHAHwZs6x1u7o-J5OHhN3Or9JHrphQWtRNQWt4F7Plhnmo1TEJSsGB7hFaR6KPbGTFMEsGiIRJu8Kc8BywRYy3nBimwl6-8vf58WR4EHi-IM-6NHgqAW1Ff4pjj9WIDZS05mZ49HJX-4FpRZV1-XAbgUqctcJ-hu-OKUgBBvgONdtajW3pkFeT7INmB-1xpwk_K3vhAjA8AzIFsFuR_IPluDhhzSaTPwnPN8SDSid4E3vwj9h5JGCKgqt5LJw8wcDESxDtb-sV3yfbL7wNqQ0XaXwu4dX1bdzWCrwnECfCxgTgNozByXEdheyCcvw7Yjh548nT7etmyCJ7U0lruFdbTRPgQ3i240hpw8_rt59Y2zj10J_5wrVGeHKOwwKVRZ2PRwknNSwOfaPypwwekjLj-JtsfW2kdgfS8vah7EIbSl1vAA1KkNMvYeIFSKeKQ4gPpVZG0sy4Y1IH-Mbbn1rNczzZ5bkmHFZQ0Sq4CDgYnTrNJEydoyjTWpHAJZqEfRNdbqNyVJFgTrpoiaZ6TZ76ywkos3riQs6YBVbCMMD4qaavV8I_OmIUxqYBLLQbV4GrWsuitnYxz4cexo_zPVUjeaSPl4evzNGn1Gyks9iaMmdHQIsuydbTqi5TXac5yXmPapKylRZViXrXrLOdpkuYrySuUpggy4mYjDYl34YYj269EwSLGoizexOQw2oQtZjyOWZOtn3me502QRkiNLUOnI1S6W-nCS6rmztClFMaayyU3RnQjoqcj_3y2vdLFxK2xeFx56sJL_wvC4vdG">