<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61906>61906</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] `std::type_index::operator<=>` may call `__builtin_strcmp` twice
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
frederick-vs-ja
</td>
</tr>
</table>
<pre>
When the two referenced `type_info` are not equal, the current implementation of `type_index::operator<=>` in libc++ may needed to call `__builtin_strcmp` twice (each in `type_info::operator==` and `type_info::before`).
https://github.com/llvm/llvm-project/blob/219ff07f72c4ff5ec0563678fceaa60e1bddd56d/libcxx/include/typeindex#L92-L98
IIUC whenever it's necessary to call `__builtin_strcmp` from `operator<=>`, we should just call it once and return `__builtin_strcmp(...) <=> 0`. Perhaps it would be better to add a member function to `type_info` for convenience.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk09vszgQxj_NcLGCHAMGDhzaZpEq9bCX1R4jY4-Du8bO2iZpvv3KRN2-fyr1fSWED2Z-zDPzPCJGc3KIAzSP0BwKsabZh0EHVBiM_Gd3ibtXUUxe3Ya_Z3QkzUjS1ZOAGgM6iYoAp-l2xqNx2gOnRAQkzieC_67CAnvaauQaArpEzHK2uKBLIhnviNfflCt8g-oBqgd_xiCSD1A9QXWA6o-MNY5YM0lgj8AeySJuxCEqVCR5IoW1GXQ8TquxybhjTEEu51yXrkYiAdahkHOmfNfvD_875CdrcOqT7ybUPiBwCqwvgR6APswpnWO-ZSOw8WTSvE6l9Auw0drL-7E7B_-KMgEbJ-snYCPb91rTVrdM1lo3KGnDK952WqIQnOJ-Uko1XGWAmeTbG7DROGlXhcDG3Nd9Xqx66dnupe_u7dzfz89_PZHrjA4vGIhJwNpIHEqMUYTbVwPTwS_57rMt5HVekcTZr1aR1zWmO8ok4p3EbW4B0xrcp3TWlWUJrCf_MwkFTkvyJ4ZZnGPmXDf0hGTClDDkboVSRJAFlwkD0auTm3eS_8l62gcivbugM9mbZaGGSvVVLwoc9ryjdU8bTot5kKzrucC-4l3V877rJFa8bvbY1lyrti_MwCiraE0ryhpOacm7fLac17rvWl1DTXERxpZ5v6UPp8LEuOLA9z3lhRUT2vieqjBsJpjWU4SaWhNT_ChLJtktfx_uhuaQpcWk7r77pXzkRHyZg2INdvhtz27KIrBxE_dfAAAA__8jx1cO">