[libcxx-commits] [PATCH] D152753: [libc++] Refactor __debug_three_way_comp
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 12 14:20:27 PDT 2023
ldionne created this revision.
ldionne added reviewers: H-G-Hristov, philnik.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, jplehr, sstefan1.
Herald added a project: libc++.
Herald added a reviewer: libc++.
This makes __debug_three_way_comp consistent with __debug_less and
in particular gets rid of a potential use-after-move caused by the
use of std::forward. In the previous version of the code, we would
call `__do_compare_assert` after forwarding the arguments into the
comparator, which could end up using the arguments after they've been
moved from.
This also simplifies how we call `__do_compare_assert` by using
`if constexpr` and adds a missing test for proxy iterators in
lexicographical_compare_three_way, which could have found this
issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152753
Files:
libcxx/include/__algorithm/three_way_comp_ref_type.h
libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way.pass.cpp
libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way_comp.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152753.530668.patch
Type: text/x-patch
Size: 4089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230612/3c63732a/attachment-0001.bin>
More information about the libcxx-commits
mailing list