<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/89591>89591</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            libstdc++ sort does not work... well
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kelbon
      </td>
    </tr>
</table>

<pre>
    Recently I wanted to sort 2 separate arrays, one with the keys, the other with their corresponding values. A year ago this worked (iota } transform (tie(key, value)) + sort), but now, after improvements and corrections to the standard, this is no longer possible.
But during the implementation process I discovered bugs/oddities in the libstd++ standard library:

1. even if range is std::sortable, stable_sort may be throw compilation error:

https://godbolt.org/z/M8hWz1G7W

This error may be even worse if you use 'size_t' indexes:

https://godbolt.org/z/nzqqPWhd3

2. std::make_unsignedhas no specialization for __int128_t, but it is used:

https://godbolt.org/z/GPa9E4h5a


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk8GO2zgMhp9GuRA1Ytmp44MPmc6m6GGBYrHAHAPZYmJtZNEV6WSTp19IbreD3npJZAo_-ZH6aZjdJSB2aveidq8bs8hIsbui7ylserKP7i8cMIh_wBe4myBoQQiYooAGxtlEIwgmRvNgpT8BBYS7kxFkRLjiGkxnkhHj_1cuwkAxIs8UrAsXuBm_IBdwgAeaCOZCIKNjuFO8ogWl947EgGpeQaIJfKY4pag4VHp_xUeqk5Mo3SrdgtIvGTN_foJ-EQh0T0dzFozgpjnSDScMwmCCXXkGcRQ4tZiYWUywJtq1B8fgGAKBp3DBCDMxu95jobavant4WQTsElMzSeum2efsJqWEOdKAzPAFrOOBbhjRQr9cWOkjWevEIYMLWepdz2KVfsk9fGdI0WjiQ1WHtd76WxaANwzgzhBNuGBCTOLqoKpD6t_0HhM_59Mpv9xkHtAjyBjpDgNNs_MrJcZI8ZcKo8jMKaaPSh8vZHvyUlC8KH18Kn38cz--PcvPzdt70d9pWjnbj2KZ8k6RMbE-aIGFEZRu2D3xJEo34ILFf5F_s354fvv29W201XuRLn5OYTJXPC0hO92OJj8hzzg4491z7ftMEU4nF6TU-8Sy-sVJmubCaH8T6fNX0_5RjzvzXrSxXWXbqjUb7MqmrJq9_liVm7Eb7HaPzcda7-rW9sYMVV1qje2-rJpzM9iN6_RW19ta63JbV7uyGLC2VaVtfzaN1eePqt7iZJwvvL9NiWPjmBfs9u2uLTfe9Og5r7jWAe-QL5XWaeNjlzQfshPrrXcs_DOLOPHYrXYcfvgxGcgSpjFKXs-iKOCO3m-W6LtfRuNkXPpioEnpY0r7_e_DHOkfHETpY4ZJW5Bh_wsAAP__ZWd9Pg">