[libcxx-commits] [PATCH] D130330: [libc++][NFC] Add checks for lifetime issues in classic algorithms.

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 26 00:52:40 PDT 2022


var-const added inline comments.


================
Comment at: libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp:65
+
+    Value(Value&& rhs) TEST_NOEXCEPT : i_(rhs.i_) {
+      assert(lifetime_cache.contains(&rhs));
----------------
Mordante wrote:
> This can be `noexcept` since we only support C++11 and later.
Done. There are a few leftovers from my attempt to make it work in C++03.


================
Comment at: libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp:653
+int main(int, char**) {
+  test_all();
+
----------------
Mordante wrote:
> Do you expect `test_all` to grow? Otherwise it could be folded in main.
Probably -- I have at least one addition in mind (I also have a personal preference for a very simple `main`).


================
Comment at: libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp:551
+
+  test(simple_in, [&](I b, I e) { std::any_of(b, e, is_neg); });
+  test(simple_in, [&](I b, I e) { std::all_of(b, e, is_neg); });
----------------
Mordante wrote:
> var-const wrote:
> > I don't know of a good way to pass a pointer to a template function, so unlike similar tests for range algorithms I'm using lambdas here.
> You mean a pointer to `std::any`?
I think using `any` here would prevent running this test in pre-C++17 modes, right? (good idea, though)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130330/new/

https://reviews.llvm.org/D130330



More information about the libcxx-commits mailing list