[all-commits] [llvm/llvm-project] 99e5c5: [libc++] Fix std::__debug_less in c++17.

Jordan Rupprecht via All-commits all-commits at lists.llvm.org
Thu Feb 10 08:54:24 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 99e5c5256ff2eeebd977f2c82567f52b1e534a1f
  Author: Jordan Rupprecht <rupprecht at google.com>
  Date:   2022-02-10 (Thu, 10 Feb 2022)

  Changed paths:
    M libcxx/include/__algorithm/comp_ref_type.h
    M libcxx/test/libcxx/algorithms/debug_less.pass.cpp

  Log Message:
  [libc++] Fix std::__debug_less in c++17.

b07b5bd72716625e0976a84d23652d94d8d0165a adds a use of `__comp_ref_type.h` to `std::min`. When libc++ is built with `-D_LIBCPP_DEBUG=0`, this enables `std::__debug_less`, which is only marked constexpr after c++17.

`std::min` itself is marked as being `constexpr` as of c++14, so by extension, `std::__debug_less` should also be marked `constexpr` for the same versions so that `std::min` can use it. This change lowers the guard from `> 17` to `> 11`.

Reproducer in godbolt: https://godbolt.org/z/ans3TGsj8


constexpr int x() { return std::min<int>({1, 2, 3, 4}); }

static_assert(x() == 1);

Reviewed By: #libc, philnik, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D118940

More information about the All-commits mailing list