[libcxx-commits] [libcxx] [libc++][hardening] Categorize more assertions. (PR #75918)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 21 12:42:18 PST 2023


================
@@ -73,7 +73,8 @@ class directory_iterator {
   _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default;
 
   _LIBCPP_HIDE_FROM_ABI const directory_entry& operator*() const {
-    _LIBCPP_ASSERT_UNCATEGORIZED(__imp_, "The end iterator cannot be dereferenced");
+    // Note: this check duplicates a check in `__dereference()`.
----------------
ldionne wrote:

Discussion just now, we discussed this by elimination:
- We think we should not do `#1` because the fast mode should be fast, so we should remove duplicate checks
- `#2` is just going to make us scratch our head in the future, it seems that `#3` is strictly better in that case
- `#3` is OK, but we lose the property of having early diagnostics with more meaningful error messages in the case where the extensive mode is enabled. So it is worse than `#4` and `#5`.
- `#4` has the benefit over `#5` that we can retain the real category of the assertion, so it's kinda cleaner in that way. But either would work.

It seems we have a preference for `#4` over `#5`, although not an extremely strong one.

https://github.com/llvm/llvm-project/pull/75918


More information about the libcxx-commits mailing list