[libcxx-commits] [PATCH] D101674: [libc++] [LIBCXX-DEBUG-FIXME] Constexpr char_traits::copy mustn't compare unrelated pointers.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 5 10:53:43 PDT 2021

ldionne requested changes to this revision.
ldionne added a comment.
This revision now requires changes to proceed.

We should be able to compare pointers with `std::less` to solve this problem. It won't work if you just start using `std::less` because our `std::less` is actually wrong, however that's another problem we need to solve. We shouldn't just remove this assertion and hide the problem. So:

1. Fix `std::less` so that it's not UB to use it to compare unrelated pointers (will require having some sort of special contract with the compiler that `std::less` can do that -- this could be done with some sort of builtin).
2. Fix the debug mode so that it allows comparing unrelated pointers with `std::less` (frankly I'm not sure what's the best way of doing that off the top of my head, but we can explore).
3. Use `std::less` to implement those pointer comparisons.


  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list