https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #10 from Fedor Chelnokov <fchelnokov at gmail dot com> --- It seems that both libc++ and MS STL implement std::sort without a temporary object passed to cmp, because they are fine with compiling the following code in constant expression (where unrelated pointers cannot be compared): consteval void foo() { std::array<int,3> nums{1, 5, 4}; auto cmp = [](auto& a, auto& b) { return &a < &b; }; std::sort(nums.begin(), nums.end(), cmp); } Online demo: https://godbolt.org/z/jdecfP6c4 Is it right that their implementations are less optimal because of no temporary object?