https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118185
Bug ID: 118185 Summary: ranges::clamp doesn't perfectly forward its projected arguments Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ppalka at gcc dot gnu.org CC: de34 at live dot cn, hewillk at gmail dot com, ppalka at gcc dot gnu.org, unassigned at gcc dot gnu.org, webrown.cpp at gmail dot com Depends on: 100249 Target Milestone: --- +++ This bug was initially created as a clone of Bug #100249 +++ (In reply to Jiang An from comment #13) > This is not completely fixed. > > See > - https://github.com/microsoft/STL/issues/3970#issuecomment-1681524306 > - https://gcc.godbolt.org/z/3fsdbTx5Y #include <algorithm> #include <concepts> struct Comp { bool operator()(const int&& x, const int&& y) const { return x < y; } bool operator()(const int&& x, int& y) const { return x < y; } bool operator()(int& x, const int&& y) const { return x < y; } bool operator()(int& x, int& y) const { return x < y; } bool operator()(std::same_as<const int&> auto && x, std::same_as<const int&> auto && y) const { return x < y; } }; struct Proj { const int&& operator()(const int& x) const { return std::move(x); } }; static_assert(std::indirect_strict_weak_order<Comp, std::projected<const int*, Proj>>); void f() { std::ranges::clamp(0, 1, 2, Comp{}, Proj{}); } Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100249 [Bug 100249] missing forwarding std::__invoke result in ranges::is_permutation and ranges::clamp