[libcxx-commits] [PATCH] D147089: [libc++] Add assertions for potential OOB reads in std::sort

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 29 07:50:53 PDT 2023


jloser added inline comments.


================
Comment at: libcxx/include/__algorithm/sort.h:298
         __j = __k;
+        _LIBCPP_ASSERT(__j != __leftmost, "Would read OOB, is your comparator a valid strict-weak ordering?");
       } while (__comp(__t, *--__k)); // No need for bounds check due to the assumption stated above.
----------------
I like the idea here, but can we spell out OOB here to be out of bounds? Given that this is a user facing message, I don't think we should be using the shorthand form. This applies below too in the other uses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147089



More information about the libcxx-commits mailing list