https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121913
Bug ID: 121913
Summary: ranges::rotate should use ranges::iter_move
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <algorithm>
struct A { };
struct B {
B() = default;
B& operator=(const B&) = delete;
B& operator=(const A&) const;
operator A() const;
};
struct I {
using value_type = A;
using difference_type = int;
B operator*() const { return {}; }
I& operator++() { ++pos; return *this; }
I operator++(int) { I tmp = *this; ++pos; return tmp; }
bool operator==(const I& i) const { return pos == i.pos; }
friend A iter_move(const I&) { return {}; }
auto operator<=>(const I&) const = default;
I& operator--() { --pos; return *this; }
I operator--(int) { I tmp = *this; --pos; return tmp; }
I& operator+=(int n) { pos += n; return *this; }
I& operator-=(int n) { pos -= n; return *this; }
B operator[](int n) const { return *(*this + n); }
friend I operator+(I i, int n) { return i += n; }
friend I operator-(I i, int n) { return i -= n; }
friend I operator+(int n, I i) { return i += n; }
friend int operator-(I i, I j) { return i.pos - j.pos; }
int pos;
};
static_assert( std::random_access_iterator<I> );
int main() {
std::ranges::rotate(I{0}, I{1}, I{2});
}
In file included from /usr/include/c++/15/algorithm:65,
from rotate.cc:1:
/usr/include/c++/15/bits/ranges_algo.h: In instantiation of ‘constexpr
std::ranges::subrange<_Iter1> std::ranges::__rotate_fn::operator()(_Iter,
_Iter, _Sent) const [with _Iter = I; _Sent = I]’:
rotate.cc:42:22: required from here
42 | std::ranges::rotate(I{0}, I{1}, I{2});
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/15/bits/ranges_algo.h:1404:44: error: use of deleted function
‘B& B::operator=(const B&)’
1404 | *(__p + __n - 1) = std::move(__t);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
rotate.cc:7:6: note: declared here
7 | B& operator=(const B&) = delete;
| ^~~~~~~~
/usr/include/c++/15/bits/ranges_algo.h:1404:44: note: use
‘-fdiagnostics-all-candidates’ to display considered candidates
1404 | *(__p + __n - 1) = std::move(__t);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/15/bits/ranges_algo.h:1430:32: error: use of deleted function
‘B& B::operator=(const B&)’
1430 | *__p = std::move(__t);
| ~~~~~^~~~~~~~~~~~~~~~
rotate.cc:7:6: note: declared here
7 | B& operator=(const B&) = delete;
| ^~~~~~~~
/usr/include/c++/15/bits/ranges_algo.h:1430:32: note: use
‘-fdiagnostics-all-candidates’ to display considered candidates
1430 | *__p = std::move(__t);
| ~~~~~^~~~~~~~~~~~~~~~