[libcxx-commits] [PATCH] D118049: [libcxx][test] the domain of == for forward iterators is iterator values from the same range

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 24 10:07:54 PST 2022


Quuxplusone added inline comments.


================
Comment at: libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/ranges_uninitialized_copy.pass.cpp:221
     int out[N] = {6, 7, 8, 9, 10};
-    assert(!std::equal(in, in + N, in, out + N));
+    assert(!std::equal(in, in + N, out, out + N));
 
----------------
CaseyCarter wrote:
> Quuxplusone wrote:
> > Mild yikes. Did MSVC catch this with a warning, instrumented debug iterators, or otherwise?
> Range validity checks - we check `first <= last` when both are pointers - caught both occurrences when the compiler decided to place `out` before `in` on the stack.
Ah, neat (but also disappointingly arbitrary :)). I wonder if there's a Clang option to randomize stack layout, or if ASAN/MSAN/UBSAN would catch unrelated pointer comparisons like that and if so could we turn it on for our debug-build CI, which also includes variations on `_LIBCPP_ASSERT(first <= last)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118049



More information about the libcxx-commits mailing list