<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68434>68434</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libc++ disagrees with libstd++ on constexpr std::string construction legality
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
The following code compiles with libstd++, but not libc++:
```
#include <iostream>
#include <string>
struct S {
std::string s_;
};
constexpr S s{"Test"};
int main() {
std::cout << s.s_;
return 0;
}
```
Online repro: https://godbolt.org/z/fjdnrPceh
It seems like either this is legal or it isn't. I'm not well-versed in the minutiae of constexpr std::strings in C++20, but my layman's impression is that this ought to work, so libstdc++ is correct and libc++ is wrong?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0U12P6jYQ_TXOy2iRsSGBhzywbCPdp1a6-1458STxrmMjz2Qp_fWVAxV0y5UsQzxfZ86cMURuCIi12L6K7VthZh5jqk-fhtiFoWijvdTvI0IfvY9nFwbookXo4nRyHgnOjkfwriW2Qr0u5wjtzBAi5_fu9qoPQr4JeRClvJ3rp9IudH62CEIfXSROaCahf3tmJk4uDHfjchOnuWP4CaJ6vb4AZDD6IPThGgH0p9A3o6je7v-Xu4uBGP86JfgJlJMo9Y7EQqn_-7rAMBkXhNoJtX9asoszZ7BCH4FWD5UBEvKcAsj_gHnKynL_HrwLCAlPKQp9gJH5RLmIaoRqhmjb6HkV0yBU87dQTf9hQ_qjw_ExyQ8GQpwIvPtEQMcjJuDRETgCj4PxEBM4BkdBqIpX8EOoalrGd0bvX74wEVpwAXhEmFyY2RmE2MOduG98U_Y-Xgev5L-CmC7gzWUyuQyBm04JiVwMGQiPhq-o4jyMDBzhHNNnDqV4k9dNSdm9iylhx2CCfdBYtpxTzAppCltru9d7U2C9Lvdlud6UShdj3du-2_dVt-utbXVZraWspLbtGm2127RV4WollV5LWa6rrVxvVqXZaomtbnd238u2FBuJk3F-5f3XlOkvHNGMdbnb6E3hTYuelnVS6kH_SuX1SnUOemnngcRGekdM9zTs2GP90I91ZIaEz7YMYvg1_1dLXotM7zJkx5diTr7-piHH49yuujgJ1WQct5-XU4of2LFQzdIbCdUs7f0TAAD__4IcSOk">