Skip to content

<algorithm>: ranges::inplace_merge accidentally constructed remove_cvref_t<iter_rvalue_reference_t<I>> #4108

@hewillk

Description

@hewillk

This is basically a sibling of #4102.

STL/stl/inc/algorithm

Lines 7614 to 7630 in 1c59a20

template <bidirectional_iterator _It>
void _Rotate_one_right(_It _First, _It _Mid, _It _Last) {
// exchanges the range [_First, _Mid) with [_Mid, _Last)
_STL_INTERNAL_CHECK(_RANGES next(_Mid) == _Last);
auto _Temp = _RANGES iter_move(_Mid);
_RANGES _Move_backward_common(_First, _STD move(_Mid), _STD move(_Last));
*_First = _STD move(_Temp);
}
template <bidirectional_iterator _It>
void _Rotate_one_left(_It _First, _It _Mid, _It _Last) {
// exchanges the range [_First, _Mid) with [_Mid, _Last)
_STL_INTERNAL_CHECK(_RANGES next(_First) == _Mid);
auto _Temp = _RANGES iter_move(_First);
auto _Result = _RANGES _Move_unchecked(_STD move(_Mid), _STD move(_Last), _STD move(_First));
*_Result.out = _STD move(_Temp);
}

auto _Temp = _RANGES iter_move(_Mid) unexpectedly constructed remove_cvref_t<iter_reference_t<I>>.

Contrived testcase: https://godbolt.org/z/b7YqKPMej

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions