https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104561

            Bug ID: 104561
           Summary: std::ranges::sort, std::ranges::stable_sort and
                    std::ranges::partial_sort do not support proxy
                    references
           Product: gcc
           Version: og11 (devel/omp/gcc-11)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Berenger.Berthoul at onera dot fr
  Target Milestone: ---

std::ranges::sort, std::ranges::stable_sort and std::ranges::partial_sort are
implemented by calls to the old std::sort, std::stable_sort and
std::partial_sort

This is wrong because the non-range algorithms assume that the reference type
of the iterator is a true C++ reference, so it does not work with proxy
references.

I have some code with a proxy reference type that (I think) demonstrates the
problem. However it would be non-trivial to extract in a complete compilable
example... I can do it if necessary, but I don't think this is needed, I am
sure libstdc++ devs know the problem since most other std::ranges:: algorithms
were implemented without the use of the non-range equivalent. (As a side-note,
using std::ranges::partition, it is pretty easy to come up with a quicksort
that works with proxy references)

So my guess would be that the developpers know the problem but did not have
time to implement a correct std::ranges::sort (and the like). But I was unable
to find anything (bug report, standard conformance limitation...). The page
https://en.cppreference.com/w/cpp/compiler_support says that C++20 ranges are
completely implemented since GCC 10.

I am understanding things correcly here?

Reply via email to