[libcxx-commits] [libcxx] [libc++][hardening] Categorize assertions related to strict weak ordering (PR #77405)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 9 14:23:38 PST 2024
================
@@ -283,9 +283,20 @@
// - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
// the containers have compatible allocators.
//
+// - `_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN` -- checks that the given argument is within the domain of valid arguments
+// for the function. Violating this typically produces an incorrect result (e.g. the clamp algorithm returns the
+// original value without clamping it due to incorrect functors) or puts an object into an invalid state (e.g.
+// a string view where only a subset of elements is possible to access). This doesn't cause an immediate issue within
+// the library but is always a logic bug and is likely to cause problems within user code.
+// This is somewhat of a catch-all (or fallback) category -- it covers errors triggered by user input that don't have
+// a more specific category defined (which is always preferable when available).
+//
// - `_LIBCPP_ASSERT_PEDANTIC` -- checks prerequisites which are imposed by the Standard, but violating which happens to
// be benign in our implementation.
//
+// - `_LIBCPP_ASSERT_INTRUSIVE` -- for assertions that perform intrusive and typically very expensive validations of
----------------
ldionne wrote:
I am not a huge fan of the word "intrusive", but I could live with it. However, I would suggest maybe piggy-backing on the notion of a "semantic constraint" or "semantic requirement" would be fruitful, since that's what this strict-weak-ordering checking is doing.
https://github.com/llvm/llvm-project/pull/77405
More information about the libcxx-commits
mailing list