[PATCH] D144834: [ADT] Fix const-correctness issues in `zippy`

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 19:47:33 PST 2023


kuhar added inline comments.


================
Comment at: llvm/unittests/ADT/IteratorTest.cpp:501-502
+  unsigned iters = 0;
+  for (auto [a, b, c] : zip_equal(SmallVector<int>{1, 2, 3}, std::string("abc"),
+                                  std::vector<bool>{true, false, true})) {
+    a = 3;
----------------
kuhar wrote:
> dblaikie wrote:
> > Does this code work? How? Wouldn't the lifetimes of the temporary ranges expire before the body of the loop runs?
> These ranges get moved into the `tuple<...> storage;` inside `zippy`. From then on, we can use references obtained from this `storage` to access them. So this should not rely on any lifetime extensions on the temporaries passed to `zip_equal`.
To confirm, I ran this under ASan and UBSan and they don't report anything once I fixed the definition of `MakeConst`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144834



More information about the llvm-commits mailing list