STL
STL copied to clipboard
`<algorithm>`: `ranges::minmax` accidentally constructed `remove_cvref_t<iter_reference_t<I>>`
https://github.com/microsoft/STL/blob/1c59a205787f4fdcd9c20decc8fa6dfa9096d394/stl/inc/algorithm#L10108-L10116
The last auto _Prev = *_UFirst; indicates that we constructed remove_cvref_t<iter_reference_t<I>> from iter_reference_t<I>, which is not guaranteed to be well-formed by the function's constraints.
I believe we should do _Vty _Prev(*_UFirst); instead.
Contrived testcase: https://godbolt.org/z/Gdb8qffdM
Good catch - we talked about this at the weekly maintainer meeting and agree that this is a bug.
This also indicates that we have missing test coverage of ranges algorithms with this scenario.