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

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 26 04:17:05 PDT 2022


huixie90 added a comment.

LGMT



================
Comment at: libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp:139
+      rhs.moved_from_ = true;
+
+      lifetime_cache.insert(this);
----------------
optional: it might be worth setting `rhs.v_` to `nullptr`, which would likely cause segv in case we are trying to deference the moved-from `Reference`


================
Comment at: libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp:157
+      assert(!rhs.moved_from_);
+      assert(rhs.moved_from_ = true);
+
----------------
is this intended? why is the assignment inside an `assert`. I think in general it is not a good idea to make `assert` have side effects, as it makes program behaves differently with different compiler flags


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